forked from prathimacode-hub/Awesome_Python_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext_episode_fetcher.py
49 lines (46 loc) · 1.62 KB
/
next_episode_fetcher.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
import requests
import bs4
from tkinter import *
from tkinter import messagebox
#fetching the data from url
def nextdate(name):
try:
res = requests.get("https://www.episodate.com/tv-show/" + name)
soup = bs4.BeautifulSoup(res.text, 'html.parser')
next_air_date = soup.find('div', {'class': 'countdown'})
next_episode = str(next_air_date)[34:63]
next_episode = next_episode.replace('"', "")
next_episode = next_episode.replace("status", "")
next_episode = next_episode.replace("/div><", "")
next_episode = next_episode.replace("class=><a href=/sear",
"Show not Found")
if (next_episode == None):
check = soup.find('div', {
'class': 'countdown'
}).find('div', {"class": "status"})
check_status = check.getText()
return check_status
else:
return next_episode
except:
return "Show Not Found"
## function for confirming the data
def function():
value = nextdate(e.get().lower())
mylabel = Label(frame, text=e.get() + " " + value)
mylabel.pack()
messagebox.showinfo("Next airing date: " + e.get(), value)
#defining the main output grid
value = ""
root = Tk()
root.title("Next Episode date")
frame = LabelFrame(root,
text="Find your TV Show/anime next Episode Date:",
padx=5,
pady=5)
frame.pack(padx=10, pady=10)
e = Entry(frame, width=25)
e.pack()
b = Button(frame, text="search", command=function)
b.pack()
root.mainloop()