forked from agarwalsarthak121/web_crawlers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
episode_down_checker.py
75 lines (69 loc) · 2.27 KB
/
episode_down_checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /usr/bin/python
import requests
from selenium import webdriver
from bs4 import BeautifulSoup
import pynotify
from time import sleep
import os
import re
#Getting search results
anime_list = 'http://animeshow.tv/anime-list.html'
sc = requests.get(anime_list)
soup = BeautifulSoup(sc.text,'lxml')
anime = soup.select('li a')
search = raw_input('Enter anime name: ')
j = 0
animes = []
for i in range(len(anime)):
if search in anime[i].text.lower():
animes.append(anime[i].get('href'))
print str(j+1)+'. '+anime[i].text
j += 1
#Selecting the anime to download
user_input = int(raw_input('Enter the anime no. to download: '))
anime_url = animes[user_input-1]
sc = requests.get(anime_url)
soup = BeautifulSoup(sc.text,'lxml')
li = soup.select('#episode-list-entry-tbl a')
li.reverse()
epi = re.compile(r'\d+')
mo = epi.search(li[-1].text)
episodes = int(mo.group())
print 'No. of Episodes:',episodes
select = int(raw_input('Enter episode to download: '))
while True:
if select > episodes:
try:
sc = requests.get(anime_url)
soup = BeautifulSoup(sc.text,'lxml')
li = soup.select('#episode-list-entry-tbl a')
li.reverse()
epi = re.compile(r'\d+')
mo = epi.search(li[-1].text)
episodes = int(mo.group())
print 'Episode not released'
sleep (60)
continue
except requests.exceptions.ConnectionError:
print 'No connection'
sleep (60)
continue
else:
ep_no = select
k = ep_no*2
print 'Downloading Episode',ep_no
pynotify.init('test')
n = pynotify.Notification('Episode '+str(ep_no)+' released','Firefox Will open Automatically and download will begin shortly')
n.show()
url = 'http://9xbuddy.com/download?url='+li[k-1].get('href')
driver = webdriver.Firefox()
driver.get(url)
sleep (15)
down = driver.find_element_by_link_text('Download Now')
href = down.get_attribute('href')
os.system('wget --output-document '+str(ep_no)+'.mp4 '+href)
print '\nDownloaded Episode '+str(ep_no)
driver.quit()
os.system('xdg-open icc_theme.mp3')
break
print 'Episode'+str()+'Downloaded'