Browse Source

add source field support

spaghetti 8 years ago
parent
commit
961e7f3ae5
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      src/py3createtorrent.py

+ 11
- 0
src/py3createtorrent.py View File

466
                       dest="private", default=False,
466
                       dest="private", default=False,
467
                       help="create private torrent")
467
                       help="create private torrent")
468
 
468
 
469
+    parser.add_option("-s", "--source", type="string", action="store",
470
+                      dest="source", default=False,
471
+                      help="include source")
472
+
469
     parser.add_option("-c", "--comment", type="string", action="store",
473
     parser.add_option("-c", "--comment", type="string", action="store",
470
                       dest="comment", default=False,
474
                       dest="comment", default=False,
471
                       help="include comment")
475
                       help="include comment")
638
     #   - piece length
642
     #   - piece length
639
     #   - name (eventually overwrite)
643
     #   - name (eventually overwrite)
640
     #   - private
644
     #   - private
645
+    #   - source
641
     # - announce
646
     # - announce
642
     # - announce-list (if multiple trackers)
647
     # - announce-list (if multiple trackers)
643
     # - creation date (may be disabled as well)
648
     # - creation date (may be disabled as well)
650
     if options.private:
655
     if options.private:
651
         info['private'] = 1
656
         info['private'] = 1
652
 
657
 
658
+    if isinstance(options.source, str):
659
+        if len(options.source) > 0:
660
+            info['source'] = options.source
661
+
653
     # Construct outer metainfo dict, which contains the torrent's whole
662
     # Construct outer metainfo dict, which contains the torrent's whole
654
     # information.
663
     # information.
655
     metainfo =  {
664
     metainfo =  {
796
           "  Size:             %s\n"
805
           "  Size:             %s\n"
797
           "  Pieces:           %d x %d KiB\n"
806
           "  Pieces:           %d x %d KiB\n"
798
           "  Comment:          %s\n"
807
           "  Comment:          %s\n"
808
+          "  Source:           %s\n"
799
           "  Private:          %s\n"
809
           "  Private:          %s\n"
800
           "  Creation date:    %s\n"
810
           "  Creation date:    %s\n"
801
           "  Primary tracker:  %s\n"
811
           "  Primary tracker:  %s\n"
806
          piece_count,
816
          piece_count,
807
          piece_length / KIB,
817
          piece_length / KIB,
808
          metainfo['comment'] if 'comment'       in metainfo else "(none)",
818
          metainfo['comment'] if 'comment'       in metainfo else "(none)",
819
+         metainfo['info']['source'] if 'source' in metainfo['info'] else "(none)",
809
          "yes" if options.private else "no",
820
          "yes" if options.private else "no",
810
          creation_date,
821
          creation_date,
811
          metainfo['announce'],
822
          metainfo['announce'],

Loading…
Cancel
Save