-
Notifications
You must be signed in to change notification settings - Fork 0
/
getIMDBInfo.py
68 lines (52 loc) · 2.1 KB
/
getIMDBInfo.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
import sys
import subdb
import opensubtitle
import gzip
import urllib.request as urllib2
from io import BytesIO
import re
import zipfile
import socket
from messagebox import messagebox as display
#Now loading the file..
if __name__ == "__main__":
#Commenting temporarilly
url_path=sys.argv[1]
#f_err = open("err_log.log", "w")
#sys.stdout = f_err
#Subtitle file name
sub_file_name = subdb.sub_file(url_path)
#First try subtitle from opensubtitle....
print('Connecting to openSubtitle...')
try:
conn = opensubtitle.OpenSubtitle(url_path,'robinskumar73','subseek2014',True)
#Search for subtitle in opensubtitle.org
results = conn.SearchSubtitles()
if results:
#Download subtitle
#Now checking for data in result...
data = results
movieName = data['title']
year = data['year']
movie_genre = ''
plot = data['plot']
if data['genres']:
for genre in data['genres']:
if movie_genre == '':
movie_genre = movie_genre + '' + genre
else:
movie_genre = movie_genre + " | " + genre
rating = data['rating']
#Now showing info...
display("IMDB INFO.", " Movie Name: " + movieName + "\n Rating: " + rating + "\n\n Year release: " + year + "\n Genre: " + movie_genre +"\n\n Plot: " + plot + "..." )
#Now closing session from opensubtitles
'Logging out from opensubtitle server'
conn.logout()
else:
#Now closing session from opensubtitles
conn.logout()
display("Sorry movie info not found","Sorry movie info not found")
except socket.gaierror:
display("Unable to connect to the internet", "Check your internet connection.")
except:
display("Sorry movie info not found","Sorry movie info not found.")