Added functionality to get a different torrent rather than the very first result (cause KAT search functionality is not the best 😠

This commit is contained in:
Kepoor Hampond 2016-07-09 21:05:32 -07:00
parent a7cd1d631c
commit ba18e8026c
2 changed files with 17 additions and 20 deletions

View file

@ -63,19 +63,19 @@ On a personal judgement, we would judge that the complete meta-data parsing work
### Usage ### Usage
```bash ```bash
$ IRS (stream | download) movie <movie-name> $ 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>
``` ```
##### Examples ##### Examples
```bash ```bash
$ IRS stream movie Fight Club $ 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
``` ```
### Disclaimer ### Disclaimer
Copyrighted content may be illegal to stream and/or download in your country. Copyrighted content may be illegal to stream and/or download in your country.

17
irs.py
View file

@ -184,24 +184,21 @@ def get_album(album_name, artist, what_to_do):
def get_torrent_url(args, category): def get_torrent_url(args, category):
search_url = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:" + category)) search_url = 'https://kat.cr/usearch/' + urllib.parse.quote_plus((" ".join(args) + " category:" + category))
print (search_url)
#time.sleep(5)
search_request_response = requests.get(search_url, verify=True) search_request_response = requests.get(search_url, verify=True)
soup = BeautifulSoup(search_request_response.text, 'html.parser') soup = BeautifulSoup(search_request_response.text, 'html.parser')
choice = False choice = False
i = 0 i = 0
print ("")
while choice == False: while choice == False:
movie_page = soup.find_all("a", class_="cellMainLink")[i] movie_page = soup.find_all("a", class_="cellMainLink")
print (movie_page.string) for number in range(0,5):
a = input("%s Is this torrent what you want? Y/n " % output("q")) print ("%s. " % (number + 1) + movie_page[number].string)
if a.lower() == 'y': a = int(str(input("\n%s What torrent would you like? " % output("q")))) - 1
search_url = requests.get('https://kat.cr' + movie_page.get('href'), verify=True) if a in (0, 1, 2, 3, 4):
search_url = requests.get('https://kat.cr' + movie_page[a].get('href'), verify=True)
soup = BeautifulSoup(search_url.text, 'html.parser') soup = BeautifulSoup(search_url.text, 'html.parser')
torrent_url = 'https:' + soup.find_all('a', class_='siteButton')[0].get('href') torrent_url = 'https:' + soup.find_all('a', class_='siteButton')[0].get('href')
choice = True choice = True
elif a == 'n':
i += 1
return torrent_url return torrent_url
def main(): def main():