mirror of
https://github.com/cooperhammond/irs.git
synced 2025-01-24 06:50:58 +00:00
Wrote more of the readme and added some error catching functionality
This commit is contained in:
parent
2678937454
commit
2a3bddc568
17
README.md
17
README.md
|
@ -15,11 +15,14 @@ First, actually install python and pip:
|
||||||
|
|
||||||
Then install `requirements.txt` from the repository:
|
Then install `requirements.txt` from the repository:
|
||||||
```bash
|
```bash
|
||||||
python install -r requirements.txt
|
$ python install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
There are some more external command-line programs that are essential to movies, tv-shows, and streaming:
|
There are some more external command-line programs that are essential to movies, tv-shows, and streaming:
|
||||||
- rTorrent: [Windows](https://rtwi.jmk.hu/wiki/rTorrentOnWindows), [OSX](http://macappstore.org/rtorrent/), Ubuntu: `sudo apt-get install rtorrent`
|
- rTorrent: [Windows](https://rtwi.jmk.hu/wiki/rTorrentOnWindows), [OSX](http://macappstore.org/rtorrent/), Ubuntu:
|
||||||
|
```bash
|
||||||
|
$ sudo apt-get install rtorrent
|
||||||
|
```
|
||||||
- mpv: https://mpv.io/installation/
|
- mpv: https://mpv.io/installation/
|
||||||
- Peerflix:
|
- Peerflix:
|
||||||
- Windows: follow [this](http://blog.teamtreehouse.com/install-node-js-npm-windows) guide to install npm and then run this command:
|
- Windows: follow [this](http://blog.teamtreehouse.com/install-node-js-npm-windows) guide to install npm and then run this command:
|
||||||
|
@ -28,8 +31,14 @@ There are some more external command-line programs that are essential to movies,
|
||||||
```
|
```
|
||||||
- OSX: Same as Windows, except follow [this](http://blog.teamtreehouse.com/install-node-js-npm-mac) guide.
|
- OSX: Same as Windows, except follow [this](http://blog.teamtreehouse.com/install-node-js-npm-mac) guide.
|
||||||
- Ubuntu: Again, the same, only follow [this](http://blog.teamtreehouse.com/install-node-js-npm-linux) guide instead.
|
- Ubuntu: Again, the same, only follow [this](http://blog.teamtreehouse.com/install-node-js-npm-linux) guide instead.
|
||||||
|
- VLC: Just download and install it [here](http://www.videolan.org/vlc/index.html).
|
||||||
|
|
||||||
And that should be it! Eventually it'll be put up on pip, to make it much easier to install.
|
### Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git clone https://github.com/kepoorhampond/IngeniousRedistributionSystem.git
|
||||||
|
```
|
||||||
|
And that should be it! Eventually it'll be put up on pip, to make it much, much easier to install.
|
||||||
|
|
||||||
### Overview
|
### Overview
|
||||||
|
|
||||||
|
@ -49,6 +58,8 @@ When downloading music, the system will fill out the specific meta-data so that
|
||||||
|
|
||||||
<sup>\* Album art is slightly buggy, and tracknumber only works when downloading complete album.<sup>
|
<sup>\* Album art is slightly buggy, and tracknumber only works when downloading complete album.<sup>
|
||||||
|
|
||||||
|
On a personal judgement, we would judge that the complete meta-data parsing works ~90% of the time.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
```bash
|
```bash
|
||||||
$ IRS (stream | download) movie <movie-name>
|
$ IRS (stream | download) movie <movie-name>
|
||||||
|
|
37
irs.py
37
irs.py
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
import os, sys, time, re, select, requests, subprocess
|
import os, sys, time, re, select, requests, subprocess
|
||||||
import urllib.request, urllib.parse
|
import urllib.request, urllib.parse
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
|
@ -42,7 +43,7 @@ def embed_mp3(art_location, song_path):
|
||||||
|
|
||||||
def find_mp3(song, author):
|
def find_mp3(song, author):
|
||||||
print ("'%s' by '%s'\n" % (song, author))
|
print ("'%s' by '%s'\n" % (song, author))
|
||||||
query_string = urllib.parse.quote_plus({"search_query" : ("%s %s lyrics" % (song, author))})
|
query_string = urllib.parse.urlencode({"search_query" : ("%s %s lyrics" % (song, author))})
|
||||||
html_content = urllib.request.urlopen("http://www.youtube.com/results?" + query_string)
|
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())
|
search_results = re.findall(r'href=\"\/watch\?v=(.{11})', html_content.read().decode())
|
||||||
audio_url = ("http://www.youtube.com/watch?v=" + search_results[0])
|
audio_url = ("http://www.youtube.com/watch?v=" + search_results[0])
|
||||||
|
@ -125,7 +126,7 @@ def output(string):
|
||||||
elif string == "g":
|
elif string == "g":
|
||||||
return colored("[+]", "green")
|
return colored("[+]", "green")
|
||||||
elif string == "s":
|
elif string == "s":
|
||||||
return colored("[*]", "yellow")
|
return colored("[*]", "blue")
|
||||||
|
|
||||||
def visible(element):
|
def visible(element):
|
||||||
if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
|
if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
|
||||||
|
@ -199,7 +200,7 @@ def main():
|
||||||
what_to_do = args[i]
|
what_to_do = args[i]
|
||||||
del args[i]
|
del args[i]
|
||||||
|
|
||||||
if what_to_do not in ("download", "stream"): raise Exception
|
if what_to_do not in ("download", "stream"): raise Exception("no what-to-do")
|
||||||
|
|
||||||
media = args[i]
|
media = args[i]
|
||||||
del args[i]
|
del args[i]
|
||||||
|
@ -220,7 +221,7 @@ def main():
|
||||||
query = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:movies"))
|
query = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:movies"))
|
||||||
if what_to_do == "stream":
|
if what_to_do == "stream":
|
||||||
torrent_url = get_torrent_url(query)
|
torrent_url = get_torrent_url(query)
|
||||||
os.system('peerflix "%s" -a --mpv' % torrent_url)
|
os.system('peerflix "%s" -a -d --vlc' % torrent_url)
|
||||||
exit(0)
|
exit(0)
|
||||||
elif what_to_do == "download":
|
elif what_to_do == "download":
|
||||||
os.system("rtorrent '%s'" % get_torrent_url(query))
|
os.system("rtorrent '%s'" % get_torrent_url(query))
|
||||||
|
@ -230,19 +231,19 @@ def main():
|
||||||
query = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:tv"))
|
query = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:tv"))
|
||||||
if what_to_do == "stream":
|
if what_to_do == "stream":
|
||||||
torrent_url = get_torrent_url(query)
|
torrent_url = get_torrent_url(query)
|
||||||
os.system('peerflix "%s" -a --vlc' % torrent_url)
|
os.system('peerflix "%s" -a -d --vlc' % torrent_url)
|
||||||
exit(0)
|
exit(0)
|
||||||
elif what_to_do == "download":
|
elif what_to_do == "download":
|
||||||
os.system("rtorrent '%s'" % get_torrent_url(query))
|
os.system("rtorrent '%s'" % get_torrent_url(query))
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
raise Exception
|
raise Exception("no media")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if str(e) == "list index out of range":
|
if str(e) in ("list index out of range", "no what-to-do", "no media"):
|
||||||
print ("%s Invalid format\n" % output("e"))
|
print ("%s Either you used an invalid format, or a special character.\n" % output("e"))
|
||||||
invalid_format()
|
invalid_format()
|
||||||
else:
|
else:
|
||||||
print ("%s Something went wrong:\n" % output("e") + e + "\n")
|
print ("%s Something went wrong:\n" % output("e") + repr(e) + "\n")
|
||||||
|
|
||||||
def columns(columns):
|
def columns(columns):
|
||||||
for row in columns:
|
for row in columns:
|
||||||
|
@ -250,16 +251,16 @@ def columns(columns):
|
||||||
def invalid_format():
|
def invalid_format():
|
||||||
# I feel like there should be an easier way to write out help for command-line interfaces ...
|
# I feel like there should be an easier way to write out help for command-line interfaces ...
|
||||||
print ("Usage:")
|
print ("Usage:")
|
||||||
print (""" IRS (stream | download) movie <movie-name>
|
print (""" irs (stream | download) movie <movie-name>
|
||||||
IRS (stream | download) tv <tv-show> <episode>
|
irs (stream | download) tv <tv-show> <episode>
|
||||||
IRS (stream | download) song <song-name> by <artist>
|
irs (stream | download) song <song-name> by <artist>
|
||||||
IRS (stream | download) album <album-name> by <artist>""")
|
irs (stream | download) album <album-name> by <artist>""")
|
||||||
print ("Examples:")
|
print ("Examples:")
|
||||||
print (""" IRS stream movie Fight Club
|
print (""" irs stream movie Fight Club
|
||||||
IRS download album A Night At The Opera by Queen
|
irs download album A Night At The Opera by Queen
|
||||||
IRS stream song Where Is My Mind by The Pixies
|
irs stream song Where Is My Mind by The Pixies
|
||||||
IRS download tv mr.robot s01e01
|
irs download tv mr.robot s01e01
|
||||||
IRS stream album A Day At The Races by Queen""")
|
irs stream album A Day At The Races by Queen""")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue