mirror of https://github.com/captn3m0/Scripts.git
new script to create torrents
This commit is contained in:
parent
ffaca3fbbb
commit
1a7634b490
|
@ -111,3 +111,4 @@ This lives in my `~/projects/scripts` directory and is added to my `$PATH`. Not
|
|||
| get-nav | Get NAV of a mutual fund from the Kuvera API |
|
||||
| audiobook2video | Generates a video for a music file, with a background |
|
||||
| fix-audible-m4a | Third-party. Fixes audible m4a fiels with incorrect Audio Object Type Specific Config bit. Source: https://rentry.co/n4ost |
|
||||
| create-new-torrent| Creates a new torrent file with sensible defaults using mktorrent |
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/env python
|
||||
|
||||
import os,sys
|
||||
import subprocess
|
||||
|
||||
"""
|
||||
Creates a new torrent using mktorrent with some sensible defaults:
|
||||
--no-date
|
||||
Finds a README file and uses that as the comment
|
||||
Picks up a list of trackers from ~/.config/trackers.txt
|
||||
|
||||
Run as create-new-torrent --any --other-options /path/to/directory
|
||||
|
||||
Most common options you might want to overwrite are
|
||||
--output
|
||||
--name
|
||||
"""
|
||||
|
||||
arguments = sys.argv
|
||||
del arguments[0]
|
||||
|
||||
directory = sys.argv[-1]
|
||||
comment = None
|
||||
for file in ["README.txt", "readme.txt", "README.md", "readme.md", "README.nfo"]:
|
||||
file_path = directory + "/" + file
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, 'r') as f:
|
||||
comment = f.read()
|
||||
|
||||
if !comment:
|
||||
print("Could not find a readme file in %s" % directory)
|
||||
|
||||
tracker_file = os.path.expanduser('~/.config/trackers.txt')
|
||||
with open(tracker_file, 'r') as t:
|
||||
list = ["mktorrent"] + ["--announce=%s" % x for x in t.read().split("\n")] + ['--no-date']
|
||||
if comment:
|
||||
list+=["--comment=\"%s\""%comment]
|
||||
list += arguments
|
||||
|
||||
subprocess.run(args=list)
|
Loading…
Reference in New Issue