mirror of
https://github.com/cooperhammond/irs.git
synced 2025-03-22 16:15:05 +00:00
Soundtracks for movies
This commit is contained in:
parent
6ea0e4f68f
commit
b386df5368
14
README.md
14
README.md
|
@ -45,13 +45,15 @@ And that should be it! Eventually it'll be put up on `pip`, to make it much, muc
|
|||
Currently the system can stream or download the following:
|
||||
- Specific songs.
|
||||
- Complete albums.
|
||||
- Movies.
|
||||
- TV shows.
|
||||
- Movies. **
|
||||
- TV shows. **
|
||||
- Playlists.
|
||||
- Links
|
||||
- Comics and books.*
|
||||
- Links.
|
||||
- Soundtracks.
|
||||
- Comics and books.* **
|
||||
|
||||
<sup>\* Limited only to downloading.<sup>
|
||||
<sup>\*\* Does not currently work, because kat.cr was taken down.<sup>
|
||||
|
||||
When downloading music, the system will fill out the specific meta-data so that it will appear organized in your player of choice. It parses the following pieces of meta-data:
|
||||
- Title.
|
||||
|
@ -71,7 +73,8 @@ $ irs (stream | download) movie <movie-name>
|
|||
$ irs (stream | download) tv <tv-show> <episode>
|
||||
$ irs (stream | download) (song | album) <title> by <artist>
|
||||
$ irs (stream | download) playlist <txt-file-name>
|
||||
irs (stream | download) '<link>' <title> <author>
|
||||
$ irs (stream | download) '<link>' <title> <author>
|
||||
$ irs (stream | download) soundtrack <movie>
|
||||
$ irs download (comic <title> <run> | book <title> by <author>)
|
||||
```
|
||||
|
||||
|
@ -84,6 +87,7 @@ $ irs stream movie Fight Club
|
|||
$ irs download tv mr.robot s01e01
|
||||
$ irs stream playlist "Rock Save The Queen.txt"
|
||||
$ irs download comic Paper Girls 001
|
||||
$ irs download soundtrack Super 8
|
||||
$ irs download link 'https://www.youtube.com/watch?v=5sy2qLtrQQQ' "Stranger Things OST" "Kyle Dixon and Michael Stein"
|
||||
```
|
||||
|
||||
|
|
151
irs.py
151
irs.py
|
@ -60,10 +60,15 @@ def embed_mp3(art_location, song_path):
|
|||
)
|
||||
music.save()
|
||||
|
||||
def find_mp3(song, author):
|
||||
def find_mp3(song, author, soundtrack=False):
|
||||
try:
|
||||
print ("'%s' by '%s'\n" % (song, author))
|
||||
query_string = urllib.parse.urlencode({"search_query" : ("%s %s lyrics" % (song, author))})
|
||||
operator = 'by'
|
||||
searching = "%s %s lyrics" % (song, author)
|
||||
if soundtrack == True:
|
||||
operator = "from"
|
||||
searching = "%s soundtrack %s" % (author, song)
|
||||
print ("'%s' %s '%s'\n" % (song, operator, author))
|
||||
query_string = urllib.parse.urlencode({"search_query" : (searching)})
|
||||
html_content = urllib.request.urlopen("http://www.youtube.com/results?" + query_string)
|
||||
search_results = re.findall(r'href=\"\/watch\?v=(.{11})', html_content.read().decode())
|
||||
in_song = False
|
||||
|
@ -85,8 +90,8 @@ def find_mp3(song, author):
|
|||
except Exception as e:
|
||||
print ("%s There was an error finding the url of '%s'" % (output("e"), song) )
|
||||
|
||||
def rip_mp3(song, author, album, tracknum):
|
||||
audio_url = find_mp3(song, author)
|
||||
def rip_mp3(song, author, album, tracknum, soundtrack=False):
|
||||
audio_url = find_mp3(song, author, soundtrack=soundtrack)
|
||||
song = song.replace("/", "\\")
|
||||
command = 'youtube-dl --metadata-from-title "%(title)s" --extract-audio \
|
||||
--audio-format mp3 --add-metadata ' + audio_url
|
||||
|
@ -324,71 +329,85 @@ def download_link(link, title, artist):
|
|||
except Exception as e:
|
||||
print ("%s Error with Auto-parsing '%s'" % (output('e'), title))
|
||||
|
||||
def main():
|
||||
def rip_soundtrack(movie, what_to_do):
|
||||
try:
|
||||
i = 0
|
||||
args = sys.argv
|
||||
del args[i]
|
||||
what_to_do = args[i]
|
||||
del args[i]
|
||||
search = search_google("", "", movie + " soundtrack")
|
||||
songs = []
|
||||
|
||||
if what_to_do not in ("download", "stream"): raise Exception("no what-to-do")
|
||||
for i, j in enumerate(search):
|
||||
if j.replace("\n", "") == ',':
|
||||
songs.append(search[i - 1])
|
||||
|
||||
media = args[i]
|
||||
del args[i]
|
||||
|
||||
if media == "song":
|
||||
song = (" ".join(args)).split(" by ")
|
||||
if what_to_do == "stream":
|
||||
command = 'mpv "%s" --no-video' % find_mp3(song[0], song[1])
|
||||
if what_to_do == 'download':
|
||||
for i in songs:
|
||||
rip_mp3(i, movie, "", "", soundtrack=True)
|
||||
elif what_to_do == 'stream':
|
||||
for i in songs:
|
||||
command = "mpv '%s' --no-video" % find_mp3(i, movie, soundtrack=True)
|
||||
os.system(command)
|
||||
elif what_to_do == "download":
|
||||
rip_mp3(song[0], song[1], "", "")
|
||||
|
||||
elif media == "album":
|
||||
album_name = (" ".join(args)).split(" by ")
|
||||
get_album(album_name[0], album_name[1], what_to_do, "album")
|
||||
|
||||
elif media == "playlist":
|
||||
rip_playlist(args[-1], what_to_do)
|
||||
|
||||
elif media in ("comic", "book"):
|
||||
if what_to_do == "download":
|
||||
os.system("rtorrent '%s'" % get_torrent_url(args, media + "s"))
|
||||
exit(0)
|
||||
elif what_to_do == "stream":
|
||||
print ("\n%s Streaming is unavailable for comics and books.\n" % output("e"))
|
||||
exit(0)
|
||||
|
||||
elif media == "movie":
|
||||
if what_to_do == "stream":
|
||||
os.system('peerflix "%s" -a -d --mpv' % get_torrent_url(args, 'movie'))
|
||||
exit(0)
|
||||
elif what_to_do == "download":
|
||||
os.system("rtorrent '%s'" % get_torrent_url(args, 'movie'))
|
||||
exit(0)
|
||||
|
||||
elif media == "tv":
|
||||
if what_to_do == "stream":
|
||||
os.system('peerflix "%s" -a -d --mpv' % get_torrent_url(args, 'tv'))
|
||||
exit(0)
|
||||
elif what_to_do == "download":
|
||||
os.system("rtorrent '%s'" % get_torrent_url(args, 'tv'))
|
||||
exit(0)
|
||||
elif media == 'link':
|
||||
if what_to_do == 'stream':
|
||||
os.system('mpv "%s" --no-video' % args[0])
|
||||
exit(0)
|
||||
elif what_to_do == 'download':
|
||||
download_link(args[0], args[1], args[2])
|
||||
else:
|
||||
raise Exception("no media")
|
||||
except Exception as e:
|
||||
if str(e) in ("list index out of range", "no what-to-do", "no media"):
|
||||
print ("%s Either you used an invalid format, or a special character.\n" % output("e"))
|
||||
invalid_format()
|
||||
else:
|
||||
print ("%s Something went wrong:\n" % output("e") + repr(e) + "\n")
|
||||
print ("%s There was an error finding the soundtrack for '%s':\n%s" % (output('e'), movie, e))
|
||||
|
||||
def main():
|
||||
i = 0
|
||||
args = sys.argv
|
||||
del args[i]
|
||||
what_to_do = args[i]
|
||||
del args[i]
|
||||
|
||||
if what_to_do not in ("download", "stream"): raise Exception("no what-to-do")
|
||||
|
||||
media = args[i]
|
||||
del args[i]
|
||||
|
||||
if media == "song":
|
||||
song = (" ".join(args)).split(" by ")
|
||||
if what_to_do == "stream":
|
||||
command = 'mpv "%s" --no-video' % find_mp3(song[0], song[1])
|
||||
os.system(command)
|
||||
elif what_to_do == "download":
|
||||
rip_mp3(song[0], song[1], "", "")
|
||||
|
||||
elif media == "album":
|
||||
album_name = (" ".join(args)).split(" by ")
|
||||
get_album(album_name[0], album_name[1], what_to_do, "album")
|
||||
|
||||
elif media == "playlist":
|
||||
rip_playlist(args[-1], what_to_do)
|
||||
|
||||
elif media in ("comic", "book"):
|
||||
if what_to_do == "download":
|
||||
os.system("rtorrent '%s'" % get_torrent_url(args, media + "s"))
|
||||
exit(0)
|
||||
elif what_to_do == "stream":
|
||||
print ("\n%s Streaming is unavailable for comics and books.\n" % output("e"))
|
||||
exit(0)
|
||||
|
||||
elif media == "movie":
|
||||
if what_to_do == "stream":
|
||||
os.system('peerflix "%s" -a -d --mpv' % get_torrent_url(args, 'movie'))
|
||||
exit(0)
|
||||
elif what_to_do == "download":
|
||||
os.system("rtorrent '%s'" % get_torrent_url(args, 'movie'))
|
||||
exit(0)
|
||||
|
||||
elif media == "tv":
|
||||
if what_to_do == "stream":
|
||||
os.system('peerflix "%s" -a -d --mpv' % get_torrent_url(args, 'tv'))
|
||||
exit(0)
|
||||
elif what_to_do == "download":
|
||||
os.system("rtorrent '%s'" % get_torrent_url(args, 'tv'))
|
||||
exit(0)
|
||||
elif media == 'link':
|
||||
if what_to_do == 'stream':
|
||||
os.system('mpv "%s" --no-video' % args[0])
|
||||
exit(0)
|
||||
elif what_to_do == 'download':
|
||||
download_link(args[0], args[1], args[2])
|
||||
elif media == 'soundtrack':
|
||||
rip_soundtrack(" ".join(args[0:]), what_to_do)
|
||||
else:
|
||||
raise Exception("no media")
|
||||
|
||||
def invalid_format():
|
||||
# I feel like there should be an easier way to write out help for command-line interfaces ...
|
||||
|
@ -398,6 +417,7 @@ def invalid_format():
|
|||
irs (stream | download) (song | album) <title> by <artist>
|
||||
irs (stream | download) playlist <txt-file-name>
|
||||
irs (stream | download) '<link>' <title> <author>
|
||||
irs (stream | download) soundtrack <movie-name>
|
||||
irs download (comic <title> <run> | book <title> by <author>)
|
||||
""")
|
||||
print ("Examples:")
|
||||
|
@ -408,6 +428,7 @@ def invalid_format():
|
|||
irs download tv mr.robot s01e01
|
||||
irs stream playlist "Rock Save The Queen.txt"
|
||||
irs download comic Paper Girls 001
|
||||
irs stream soundtrack Super 8
|
||||
irs download link 'https://www.youtube.com/watch?v=5sy2qLtrQQQ' "Stranger Things OST" "Kyle Dixon and Michael Stein"
|
||||
""")
|
||||
print ("\nFor more info see: https://github.com/kepoorhampond/IngeniousRedistributionSystem")
|
||||
|
|
Loading…
Reference in a new issue