Browse Source

add source field support

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

Loading…
Cancel
Save