Wrote more of the readme and added some error catching functionality

This commit is contained in:
Kepoor Hampond 2016-07-08 13:52:43 -07:00
parent 5a11e9d8af
commit 2678937454
2 changed files with 77 additions and 88 deletions

View file

@ -4,10 +4,11 @@ Downloads or streams media from the name of the song / album / movie / tv-show t
### Dependencies
First, acutally install python and pip:
First, actually install python and pip:
- To install python3 and `pip` for Ubuntu run this command:
```bash
$ sudo apt-get install python3 python3-pip
$ sudo apt-get install python3 python3-pip
```
- For Windows follow [this](http://www.howtogeek.com/197947/how-to-install-python-on-windows/) guide to install python (remember to install ~v3.4), and [this](https://pip.pypa.io/en/latest/installing/) guide to install `pip`.
- For OSX follow [this](http://docs.python-guide.org/en/latest/starting/install/osx/) guide that goes through python and `pip`. Also, remember to install ~v3.4.
@ -47,3 +48,22 @@ When downloading music, the system will fill out the specific meta-data so that
- Tracknumber.*
<sup>\* Album art is slightly buggy, and tracknumber only works when downloading complete album.<sup>
### Usage
```bash
$ IRS (stream | download) movie <movie-name>
$ IRS (stream | download) tv <tv-show> <episode>
$ IRS (stream | download) song <song-name> by <artist>
$ IRS (stream | download) album <album-name> by <artist>
```
##### Examples
```bash
$ IRS stream movie Fight Club
$ IRS download album A Night At The Opera by Queen
$ IRS stream song Where Is My Mind by The Pixies
$ IRS download tv mr.robot s01e01
$ IRS stream album A Day At The Races by Queen
```
### Disclaimer
Copyrighted content may be illegal to stream and/or download in your country.

View file

@ -9,24 +9,6 @@ from mutagen.mp3 import MP3
from bs4 import BeautifulSoup
import youtube_dl, mutagen
"""def test_system():
try:
# Put import stuff here
except Exception as e:
e = str(e).split(" ")[-1]
print ("Please install the module %s with:\npip3 install %s")
exit(0)
if subprocess.check_output("mpv --version", shell=True) != 0:
print ("mpv is not installed, please install it with:\nsudo apt-get install mpv")
if subprocess.check_output("peerflix --version", shell=True) != 0:
print ("peerflix is not installed, install it with:\nsudo apt-get install peerflix")
if "Rakshasa" in subprocess.check_output("rtorrent -h", shell=True):
print ("rtorrent is not installed, install it with:\nsudo apt-get install rtorrent")
def quiet_output(string):
output = subprocess.check_output(string, shell=True)
"""
def download_album_art(album, band):
search = "%s %s" % (album, band)
url = "http://www.seekacover.com/cd/" + urllib.parse.quote_plus(search)
@ -210,8 +192,7 @@ def get_torrent_url(search_url):
return torrent_url
def main():
#test_system()
#try:
try:
i = 0
args = sys.argv
del args[i]
@ -239,7 +220,7 @@ def main():
query = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:movies"))
if what_to_do == "stream":
torrent_url = get_torrent_url(query)
os.system('peerflix "%s" -a --vlc' % torrent_url)
os.system('peerflix "%s" -a --mpv' % torrent_url)
exit(0)
elif what_to_do == "download":
os.system("rtorrent '%s'" % get_torrent_url(query))
@ -256,10 +237,12 @@ def main():
exit(0)
else:
raise Exception
"""except Exception as e:
print (e)
invalid_format()"""
except Exception as e:
if str(e) == "list index out of range":
print ("%s Invalid format\n" % output("e"))
invalid_format()
else:
print ("%s Something went wrong:\n" % output("e") + e + "\n")
def columns(columns):
for row in columns:
@ -267,30 +250,16 @@ def columns(columns):
def invalid_format():
# I feel like there should be an easier way to write out help for command-line interfaces ...
print ("Usage:")
print (" UPS [what-to-do] [type-of-media] <movie-name>")
print (" UPS [what-to-do] [type-of-media] <tv-show> [episode]")
print (" UPS [what-to-do] [type-of-media] <album> by <artist>")
print (" UPS [what-to-do] [type-of-media] <song> by <artist>\n")
print ("what-to-do:")
d_or_s = [["download", "will download the specified media"],
["stream", "will stream the specified media"]]
columns(d_or_s)
print ("type-of-media:")
media = [["song", "finds a song, needs the artist as well"],
["album", "finds all songs on the album, needs the artist as well"],
["movie", "will find a movie"],
["tv", "will find a tv show, needs to have the episode specified"]]
columns(media)
print ("tv show episode should be formatted as:")
episode = [["s01e01", "s12e01"], ["s03e05", "s05e17"], ["... ", "... "]]
columns(episode)
print ("examples:")
examples = [["$ UPS stream movie Fight Club"],
["$ UPS download album Jazz by Queen"],
["$ UPS stream song Where Is My Mind by The Pixies"],
["$ UPS download tv mr robot s01e01"]]
for row in examples:
print("\t {: >15}".format(*row))
print (""" IRS (stream | download) movie <movie-name>
IRS (stream | download) tv <tv-show> <episode>
IRS (stream | download) song <song-name> by <artist>
IRS (stream | download) album <album-name> by <artist>""")
print ("Examples:")
print (""" IRS stream movie Fight Club
IRS download album A Night At The Opera by Queen
IRS stream song Where Is My Mind by The Pixies
IRS download tv mr.robot s01e01
IRS stream album A Day At The Races by Queen""")
if __name__ == '__main__':
main()