Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
IMDB-Script/imdbScript.py at master · Manukumar1/IMDB-Script · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Manukumar1
IMDB-Script
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
IMDB-Script
/
imdbScript.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
240 lines (179 loc) · 7.15 KB
master
Breadcrumbs
IMDB-Script
/
imdbScript.py
Copy path
Top
File metadata and controls
Code
Blame
240 lines (179 loc) · 7.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# -*- coding: utf-8 -*-
"""
@author: Manu kumar
"""
############################ IMPORTING PACKAGES ##########################
from
bs4
import
BeautifulSoup
from
urllib
.
request
import
urlopen
from
datetime
import
datetime
from
datetime
import
date
import
mysql
.
connector
import
smtplib
from
email
.
mime
.
multipart
import
MIMEMultipart
from
email
.
mime
.
text
import
MIMEText
from
email
.
mime
.
base
import
MIMEBase
from
email
import
encoders
############################# MYSQL CONNECTION #####################
db
=
mysql
.
connector
.
connect
(
host
=
"localhost"
,
user
=
"root"
,
passwd
=
"root"
,
database
=
"userShows"
)
#################################### CREATION OF DATABASE ###############################
cursor
=
db
.
cursor
()
cursor
.
execute
(
"CREATE DATABASE IF NOT EXISTS userShows"
)
sql
=
"""CREATE TABLE IF NOT EXISTS ShowDetails (
Name VARCHAR(100),
Email_address VARCHAR(100),
TV_Series VARCHAR(1000)
)"""
cursor
.
execute
(
sql
)
#################################### GETTING INPUTS FROM USER ####################################
Name_input
=
input
(
"Input your name: "
)
Email_address_input
=
input
(
"Email address: "
)
TV_Series_input
=
input
(
"TV Series: "
)
fromaddr
=
"imdbscriptManukumar@gmail.com"
toaddr
=
Email_address_input
############################### MAKING CHANGES IN DATABASE ###################################
try
:
entry
=
(
"INSERT INTO ShowDetails (Name, Email_address, TV_Series) VALUES (%s, %s, %s)"
)
val
=
(
Name_input
,
Email_address_input
,
TV_Series_input
)
# Execute the SQL command
cursor
.
execute
(
entry
,
val
)
# Commit changes in the database
db
.
commit
()
print
(
"
\n
Data stored into database"
)
except
:
# Rollback in case there is any error
db
.
rollback
()
# disconnect from server
db
.
close
()
###################### OBTAINING CURRENT DATE #################################################
Status
=
[]
Ser_inv_name
=
[]
today
=
date
.
today
()
today
=
str
(
today
)
########################### WORKING ON INDIVIDUAL SERIES SEARCH #########################################
TV_Series
=
TV_Series_input
.
split
(
", "
)
l
=
(
len
(
TV_Series
))
for
indivSeries
in
TV_Series
:
Ser_inv_name
.
append
(
indivSeries
)
series_search
=
"+"
.
join
((
indivSeries
).
split
())
base_url
=
"https://www.imdb.com/search/title?title="
new_url
=
base_url
+
series_search
+
'&title_type=tv_series'
#base_url = "http://www.imdb.com/find?q="
#new_url = base_url+series_search+'&s=all'
####################### FETCHING URL SEARCH RESULTS #####################################
x
=
urlopen
(
new_url
)
source
=
x
.
read
()
#source = requests.get(new_url).text
soup
=
BeautifulSoup
(
source
,
"xml"
)
########################## FETCHING LINK OF A SPECIFIC SHOW ################################
res_url
=
soup
.
find
(
'div'
,
class_
=
'lister-item mode-advanced'
)
res_url
=
res_url
.
find
(
'div'
,
class_
=
'lister-item-content'
).
h3
.
a
res_url
=
res_url
.
get
(
'href'
)
base_res_url
=
"https://www.imdb.com"
showIMDBlink
=
base_res_url
+
res_url
####################### SCRAPPING OF DATA ###################################
y
=
urlopen
(
showIMDBlink
)
source1
=
y
.
read
()
soupa
=
BeautifulSoup
(
source1
,
"xml"
)
first_link
=
soupa
.
find
(
id
=
"main_bottom"
,
class_
=
'main'
)
seasonNum
=
first_link
.
find
(
'div'
,
class_
=
'seasons-and-year-nav'
)
currentSeason
=
seasonNum
.
find
(
'a'
)
currentSeasonNum
=
currentSeason
.
text
############################ FETCHING LINK OF LATEST SEASON ##########################
season_url
=
seasonNum
.
find
(
'a'
)
season_url
=
season_url
.
get
(
'href'
)
season_url
=
season_url
.
replace
(
"=tt"
,
"&ref_=tt"
)
seasonIMDBlink
=
base_res_url
+
season_url
# print(seasonIMDBlink)
######################### SCRAPPING FROM LATEST SEASON #################################
z
=
urlopen
(
seasonIMDBlink
)
source2
=
z
.
read
()
soupb
=
BeautifulSoup
(
source2
,
"xml"
)
################## Checking if the show has finished streaming all its episodes ###########
showOver
=
soupb
.
find
(
'div'
,
class_
=
'subpage_title_block'
)
showOver
=
showOver
.
find
(
'div'
,
class_
=
'parent'
).
h3
showOver
=
showOver
.
find
(
'span'
,
class_
=
'nobr'
).
text
.
strip
()
showOver1
=
showOver
.
split
(
"–"
)[
1
]
showOverYear
=
showOver1
.
strip
(
")"
)
if
showOverYear
!=
" "
:
emailMsg
=
"Status: The show has finished streaming all its episodes."
Status
.
append
(
emailMsg
)
# print(emailMsg)
####################### SHOW HAS NOT FINISHED STREAMING #######################################
else
:
ans
=
[]
allD
=
[]
sizes
=
[]
episodeDates
=
soupb
.
find
(
'div'
,
class_
=
'list detail eplist'
)
for
epDates
in
episodeDates
.
find_all
(
'div'
, {
"class"
:
"airdate"
}):
epDates
=
epDates
.
text
.
strip
()
epDates
=
epDates
.
replace
(
"."
,
""
)
sz
=
len
(
epDates
)
sizes
.
append
(
len
(
epDates
))
allD
.
append
(
epDates
)
if
((
sz
)
>
4
):
epDates
=
datetime
.
strptime
(
epDates
,
'%d %b %Y'
)
epDates
=
str
(
epDates
)
epDates
=
datetime
.
strptime
(
epDates
,
'%Y-%m-%d %H:%M:%S'
).
strftime
(
'%Y-%m-%d'
)
ans
.
append
(
epDates
)
n
=
len
(
ans
)
###################################################################################################################################################
if
((
len
(
str
(
allD
[
0
])))
==
4
):
epDates
=
datetime
.
strptime
(
allD
[
0
],
'%Y'
)
epDates
=
str
(
epDates
)
epDates
=
datetime
.
strptime
(
epDates
,
'%Y-%m-%d %H:%M:%S'
).
strftime
(
'%Y'
)
emailMsg
=
"Status: The next season begins in {0}."
.
format
(
epDates
)
Status
.
append
(
emailMsg
)
# print(emailMsg)
#####################################################################################################################################
else
:
for
i
in
range
(
0
,
n
):
if
(
ans
[
i
]
>
today
and
i
<
n
):
break
else
:
i
+=
1
if
(
i
==
n
):
emailMsg
=
"Status: The show has finished streaming all its episodes."
Status
.
append
(
emailMsg
)
# print(emailMsg)
else
:
emailMsg
=
"Status: Next episode airs on {0}."
.
format
(
ans
[
i
])
Status
.
append
(
emailMsg
)
# print(emailMsg)
#print(Status)
#print(Ser_inv_name)
finalbody
=
[]
finalPrintBody
=
[]
body
=
"TV Series: "
space
=
" "
for
j
in
range
(
0
,
l
):
bodyprint
=
body
+
TV_Series
[
j
]
finalbody
.
append
(
bodyprint
)
j
+=
1
#print(finalbody)
for
k
in
range
(
0
,
l
):
finalPrintBody
.
append
(
finalbody
[
k
])
finalPrintBody
.
append
(
Status
[
k
])
finalPrintBody
.
append
(
space
)
#print(*finalPrintBody,sep='\n')
msg
=
MIMEMultipart
()
msg
[
'From'
]
=
fromaddr
msg
[
'To'
]
=
toaddr
msg
[
'Subject'
]
=
"Show Details"
body
=
''
for
row
in
finalPrintBody
:
body
+=
'%s
\n
'
%
row
msg
.
attach
(
MIMEText
(
body
,
'plain'
))
mail
=
smtplib
.
SMTP
(
'smtp.gmail.com'
,
587
)
mail
.
ehlo
()
mail
.
starttls
()
mail
.
ehlo
()
mail
.
login
(
fromaddr
,
"manukumar"
)
text
=
msg
.
as_string
()
mail
.
sendmail
(
fromaddr
,
toaddr
,
text
)
mail
.
close
()
print
(
"
\n
Email sent to the provided Email address"
)
You can’t perform that action at this time.