-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
181 lines (176 loc) · 17.4 KB
/
main.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
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
# coding: utf-8
import re
import subscription
# this read the settings
settings = subscription.Settings()
# define the browser
browser = subscription.Browser()
# option
option = settings.dialog.select('Choose:', ['Genre', 'Language', 'List'])
if option == 0:
genre = { 'Action': 'http://www.imdb.com/genre/action/?ref_=gnr_mn_ac_mp',
'Action Comedy': 'http://www.imdb.com/search/title?count=100&genres=action,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_ac_1',
'Action Crime': 'http://www.imdb.com/search/title?count=100&genres=action,crime&num_votes=10000,&title_type=feature&ref_=gnr_mn_ac_2',
'Action Thriller': 'http://www.imdb.com/search/title?count=100&genres=action,thriller&num_votes=10000,&title_type=feature&ref_=gnr_mn_ac_3',
'Animation': 'http://www.imdb.com/genre/animation/?ref_=gnr_mn_an_mp',
'Animation Adventure': 'http://www.imdb.com/search/title?count=100&genres=animation,adventure&num_votes=10000,&title_type=feature&ref_=gnr_mn_an_1',
'Animation Comedy': 'http://www.imdb.com/search/title?count=100&genres=animation,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_an_2',
'Animation Family': 'http://www.imdb.com/search/title?count=100&genres=animation,family&num_votes=10000,&title_type=feature&ref_=gnr_mn_an_3',
'Animation Fantasy': 'http://www.imdb.com/search/title?count=100&genres=animation,fantasy&num_votes=10000,&title_type=feature&ref_=gnr_mn_an_4',
'Comedy': 'http://www.imdb.com/genre/comedy/?ref_=gnr_mn_co_mp',
'Comedy Action': 'http://www.imdb.com/search/title?count=100&genres=comedy,action&num_votes=10000,&title_type=feature&ref_=gnr_mn_co_1',
'Comedy Horror': 'http://www.imdb.com/search/title?count=100&genres=comedy,horror&num_votes=10000,&title_type=feature&ref_=gnr_mn_co_2',
'Comedy Romance': 'http://www.imdb.com/search/title?count=100&genres=comedy,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_co_3',
'Documentary': 'http://www.imdb.com/genre/documentary/?ref_=gnr_mn_do_mp',
'Documentary Biography': 'http://www.imdb.com/search/title?count=100&genres=documentary,biography&num_votes=1000,&title_type=documentary&ref_=gnr_mn_do_1',
'Documentary Comedy': 'http://www.imdb.com/search/title?count=100&genres=documentary,comedy&num_votes=1000,&title_type=documentary&ref_=gnr_mn_do_2',
'Documentary Crime': 'http://www.imdb.com/search/title?count=100&genres=documentary,crime&num_votes=1000,&title_type=documentary&ref_=gnr_mn_do_3',
'Documentary History': 'http://www.imdb.com/search/title?count=100&genres=documentary,history&num_votes=1000,&title_type=documentary&ref_=gnr_mn_do_4',
'Family': 'http://www.imdb.com/genre/family/?ref_=gnr_mn_fm_mp',
'Family Adventure': 'http://www.imdb.com/search/title?count=100&genres=family,adventure&num_votes=10000,&title_type=feature&ref_=gnr_mn_fm_1',
'Family Comedy': 'http://www.imdb.com/search/title?count=100&genres=family,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_fm_2',
'Family Fantasy': 'http://www.imdb.com/search/title?count=100&genres=family,fantasy&num_votes=10000,&title_type=feature&ref_=gnr_mn_fm_3',
'Family Romance': 'http://www.imdb.com/search/title?count=100&genres=family,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_fm_4',
'Film-Noir': 'http://www.imdb.com/genre/film_noir/?ref_=gnr_mn_fn_mp',
'Film-Noir Crime': 'http://www.imdb.com/search/title?count=100&genres=film_noir,crime&num_votes=10000,&title_type=feature&ref_=gnr_mn_fn_1',
'Film-Noir Mystery': 'http://www.imdb.com/search/title?count=100&genres=film_noir,mystery&num_votes=10000,&title_type=feature&ref_=gnr_mn_fn_2',
'Film-Noir Romance': 'http://www.imdb.com/search/title?count=100&genres=film_noir,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_fn_3',
'Film-Noir Thriller': 'http://www.imdb.com/search/title?count=100&genres=film_noir,thriller&num_votes=10000,&title_type=feature&ref_=gnr_mn_fn_4',
'Horror': 'http://www.imdb.com/genre/horror/?ref_=gnr_mn_ho_mp',
'Horror Comedy': 'http://www.imdb.com/search/title?count=100&genres=horror,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_ho_1',
'Horror Drama': 'http://www.imdb.com/search/title?count=100&genres=horror,drama&num_votes=10000,&title_type=feature&ref_=gnr_mn_ho_2',
'Horror Sci-fi': 'http://www.imdb.com/search/title?count=100&genres=horror,sci_fi&num_votes=10000,&title_type=feature&ref_=gnr_mn_ho_3',
'Musical': 'http://www.imdb.com/genre/musical/?ref_=gnr_mn_ml_mp',
'Musical Comedy': 'http://www.imdb.com/search/title?count=100&genres=musical,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_ml_1',
'Musical History': 'http://www.imdb.com/search/title?count=100&genres=musical,history&num_votes=10000,&title_type=feature&ref_=gnr_mn_ml_2',
'Musical Romance': 'http://www.imdb.com/search/title?count=100&genres=musical,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_ml_3',
'Romance': 'http://www.imdb.com/genre/romance/?ref_=gnr_mn_ro_mp',
'Romance Comedy': 'http://www.imdb.com/search/title?count=100&genres=romance,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_ro_1',
'Romance Crime': 'http://www.imdb.com/search/title?count=100&genres=romance,crime&num_votes=10000,&title_type=feature&ref_=gnr_mn_ro_2',
'Romance History': 'http://www.imdb.com/search/title?count=100&genres=romance,history&num_votes=10000,&title_type=feature&ref_=gnr_mn_ro_3',
'Romance Thriller': 'http://www.imdb.com/search/title?count=100&genres=romance,thriller&num_votes=10000,&title_type=feature&ref_=gnr_mn_ro_4',
'Sport': 'http://www.imdb.com/genre/sport/?ref_=gnr_mn_sp_mp',
'Sport Biography': 'http://www.imdb.com/search/title?count=100&genres=sport,biography&num_votes=10000,&title_type=feature&ref_=gnr_mn_sp_1',
'Sport Comedy': 'http://www.imdb.com/search/title?count=100&genres=sport,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_sp_2',
'Sport Documentary': 'http://www.imdb.com/search/title?count=100&genres=sport,documentary&num_votes=1000,&title_type=documentary&ref_=gnr_mn_sp_3',
'War': 'http://www.imdb.com/genre/war/?ref_=gnr_mn_wa_mp',
'War Action': 'http://www.imdb.com/search/title?count=100&genres=war,action&num_votes=10000,&title_type=feature&ref_=gnr_mn_wa_1',
'War Biography': 'http://www.imdb.com/search/title?count=100&genres=war,biography&num_votes=10000,&title_type=feature&ref_=gnr_mn_wa_2',
'War Comedy': 'http://www.imdb.com/search/title?count=100&genres=war,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_wa_3',
'War Documentary': 'http://www.imdb.com/search/title?count=100&genres=war,documentary&num_votes=1000,&title_type=documentary&ref_=gnr_mn_wa_4',
'Adventure': 'http://www.imdb.com/genre/adventure/?ref_=gnr_mn_ad_mp',
'Adventure Biography': 'http://www.imdb.com/search/title?count=100&genres=adventure,biography&num_votes=10000,&title_type=feature&ref_=gnr_mn_ad_1',
'Adventure Thriller': 'http://www.imdb.com/search/title?count=100&genres=adventure,thriller&num_votes=10000,&title_type=feature&ref_=gnr_mn_ad_2',
'Adventure War': 'http://www.imdb.com/search/title?count=100&genres=adventure,war&num_votes=10000,&title_type=feature&ref_=gnr_mn_ad_3',
'Biography': 'http://www.imdb.com/genre/biography/?ref_=gnr_mn_bi_mp',
'Biography Crime': 'http://www.imdb.com/search/title?count=100&genres=biography,crime&num_votes=10000,&title_type=feature&ref_=gnr_mn_bi_1',
'Biography Mystery': 'http://www.imdb.com/search/title?count=100&genres=biography,mystery&num_votes=5000,&title_type=feature&ref_=gnr_mn_bi_2',
'Biography Sport': 'http://www.imdb.com/search/title?count=100&genres=biography,sport&num_votes=10000,&title_type=feature&ref_=gnr_mn_bi_3',
'Crime': 'http://www.imdb.com/genre/crime/?ref_=gnr_mn_cr_mp',
'Crime Drama': 'http://www.imdb.com/search/title?count=100&genres=crime,drama&num_votes=10000,&title_type=feature&ref_=gnr_mn_cr_1',
'Crime Mystery': 'http://www.imdb.com/search/title?count=100&genres=crime,mystery&num_votes=10000,&title_type=feature&ref_=gnr_mn_cr_2',
'Crime Romance': 'http://www.imdb.com/search/title?count=100&genres=crime,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_cr_3',
'Drama': 'http://www.imdb.com/genre/drama/?ref_=gnr_mn_dr_mp',
'Drama Romance': 'http://www.imdb.com/search/title?count=100&genres=drama,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_dr_1',
'Drama Film-Noir': 'http://www.imdb.com/search/title?count=100&genres=drama,film_noir&num_votes=10000,&title_type=feature&ref_=gnr_mn_dr_2',
'Drama Musical': 'http://www.imdb.com/search/title?count=100&genres=drama,musical&num_votes=10000,&title_type=feature&ref_=gnr_mn_dr_3',
'Drama War': 'http://www.imdb.com/search/title?count=100&genres=drama,war&num_votes=10000,&title_type=feature&ref_=gnr_mn_dr_4',
'Fantasy': 'http://www.imdb.com/genre/fantasy/?ref_=gnr_mn_fa_mp',
'Fantasy Adventure': 'http://www.imdb.com/search/title?count=100&genres=fantasy,adventure&num_votes=10000,&title_type=feature&ref_=gnr_mn_fa_1',
'Fantasy Comedy': 'http://www.imdb.com/search/title?count=100&genres=fantasy,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_fa_2',
'Fantasy Drama': 'http://www.imdb.com/search/title?count=100&genres=fantasy,drama&num_votes=10000,&title_type=feature&ref_=gnr_mn_fa_3',
'Fantasy Romance': 'http://www.imdb.com/search/title?count=100&genres=fantasy,romance&num_votes=10000,&title_type=feature&ref_=gnr_mn_fa_4',
'History': 'http://www.imdb.com/genre/history/?ref_=gnr_mn_hi_mp',
'History Adventure': 'http://www.imdb.com/search/title?count=100&genres=history,adventure&num_votes=10000,&title_type=feature&ref_=gnr_mn_hi_1',
'History Biography': 'http://www.imdb.com/search/title?count=100&genres=history,biography&num_votes=10000,&title_type=feature&ref_=gnr_mn_hi_2',
'History Drama': 'http://www.imdb.com/search/title?count=100&genres=history,drama&num_votes=10000,&title_type=feature&ref_=gnr_mn_hi_3',
'History War': 'http://www.imdb.com/search/title?count=100&genres=history,war&num_votes=10000,&title_type=feature&ref_=gnr_mn_hi_4',
'Music': 'http://www.imdb.com/genre/music/?ref_=gnr_mn_mu_mp',
'Music Biography': 'http://www.imdb.com/search/title?count=100&genres=music,biography&num_votes=10000,&title_type=feature&ref_=gnr_mn_mu_1',
'Music Documentary': 'http://www.imdb.com/search/title?count=100&genres=documentary,music&num_votes=750,&title_type=documentary&ref_=gnr_mn_mu_2',
'Music Drama': 'http://www.imdb.com/search/title?count=100&genres=music,drama&num_votes=10000,&title_type=feature&ref_=gnr_mn_mu_3',
'Mystery': 'http://www.imdb.com/genre/mystery/?ref_=gnr_mn_my_mp',
'Mystery Adventure': 'http://www.imdb.com/search/title?count=100&genres=mystery,adventure&num_votes=10000,&title_type=feature&ref_=gnr_mn_my_1',
'Mystery Comedy': 'http://www.imdb.com/search/title?count=100&genres=mystery,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_my_2',
'Mystery Thriller': 'http://www.imdb.com/search/title?count=100&genres=mystery,thriller&num_votes=10000,&title_type=feature&ref_=gnr_mn_my_3',
'Sci-fi': 'http://www.imdb.com/genre/sci_fi/?ref_=gnr_mn_sf_mp',
'Sci-fi Animation': 'http://www.imdb.com/search/title?count=100&genres=sci_fi,animation&num_votes=10000,&title_type=feature&ref_=gnr_mn_sf_1',
'Sci-fi Comedy': 'http://www.imdb.com/search/title?count=100&genres=sci_fi,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_sf_2',
'Sci-fi Family': 'http://www.imdb.com/search/title?count=100&genres=sci_fi,family&num_votes=10000,&title_type=feature&ref_=gnr_mn_sf_3',
'Sci-fi Horror': 'http://www.imdb.com/search/title?count=100&genres=sci_fi,horror&num_votes=10000,&title_type=feature&ref_=gnr_mn_sf_4',
'Thriller': 'http://www.imdb.com/genre/thriller/?ref_=gnr_mn_th_mp',
'Thriller Comedy': 'http://www.imdb.com/search/title?count=100&genres=thriller,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_th_1',
'Thriller Crime': 'http://www.imdb.com/search/title?count=100&genres=thriller,crime&num_votes=10000,&title_type=feature&ref_=gnr_mn_th_2',
'Thriller Horror': 'http://www.imdb.com/search/title?count=100&genres=thriller,horror&num_votes=10000,&title_type=feature&ref_=gnr_mn_th_3',
'Thriller Mystery': 'http://www.imdb.com/search/title?count=100&genres=thriller,mystery&num_votes=10000,&title_type=feature&ref_=gnr_mn_th_4',
'Western': 'http://www.imdb.com/genre/western/?ref_=gnr_mn_we_mp',
'Western Action': 'http://www.imdb.com/search/title?count=100&genres=western,action&num_votes=10000,&title_type=feature&ref_=gnr_mn_we_1',
'Western Adventure': 'http://www.imdb.com/search/title?count=100&genres=western,adventure&num_votes=10000,&title_type=feature&ref_=gnr_mn_we_2',
'Western Comedy': 'http://www.imdb.com/search/title?count=100&genres=western,comedy&num_votes=10000,&title_type=feature&ref_=gnr_mn_we_3',
}
options = genre.keys()
options.sort()
ret = settings.dialog.select('Choose a playlist', options)
url_search = genre[options[ret]]
listing = []
ID = [] # IMDB_ID or thetvdb ID
if browser.open(url_search):
data = browser.content
for line in re.findall('<span class="wlb_wrapper"(.*?)</div>',data, re.S):
items = re.search('/title/(.*?)/(.*?)>(.*?)<', line)
year = re.search('<span class="year_type">(.*?)<', line)
ID.append(items.group(1))
listing.append(items.group(3).replace(''', "'").replace('&', '&') + ' ' + year.group(1))
subscription.integration(listing, ID, 'MOVIE', settings.movie_folder)
else:
print '[script.subscription.pulsar] %s' % browser.status
settings.dialog.notification('Pulsar List integration',browser.status, settings.icon, 5000)
elif option == 1:
#language
language = {'Arabic': 'ar', 'Bulgarian': 'bg', 'Chinese': 'zh', 'Croatian': 'hr',
'Dutch': 'nl', 'English': 'en', 'Finnish': 'fi', 'French': 'fr',
'German': 'de','Greek': 'el', 'Hebrew': 'he', 'Hindi': 'hi',
'Hungarian': 'hu', 'Icelandic': 'is', 'Italian': 'it', 'Japanese': 'ja',
'Korean': 'ko', 'Norwegian': 'no', 'Persian': 'fa', 'Polish': 'pl',
'Portuguese': 'pt', 'Punjabi': 'pa', 'Romanian': 'ro', 'Russian': 'ru',
'Spanish': 'es', 'Swedish': 'sv', 'Turkish': 'tr', 'Ukrainian': 'uk',
}
options = language.keys()
options.sort()
ret = settings.dialog.select('Choose a language', options)
url_search = 'http://www.imdb.com/search/title?languages=%s|1&sort=moviemeter,asc&start=1&title_type=feature' % language[options[ret]]
listing = []
ID = [] # IMDB_ID or thetvdb ID
if browser.open(url_search):
data = browser.content
for line in re.findall('<span class="wlb_wrapper"(.*?)</div>', data, re.S):
items = re.search('/title/(.*?)/(.*?)>(.*?)<', line)
year = re.search('<span class="year_type">(.*?)<', line)
ID.append(items.group(1))
listing.append(
items.group(3).replace(''', "'").replace('&', '&').replace(''', "'").replace('é',
'e') + ' ' + year.group(1))
subscription.integration(listing, ID, 'MOVIE', settings.movie_folder)
else:
print '[script.subscription.pulsar] %s' % browser.status
settings.dialog.notification('Pulsar List integration', browser.status, settings.icon, 5000)
elif option == 2:
#list
list = settings.dialog.input('IMDB List to add:', 'ls000009599')
if list != '':
url_search = "http://www.imdb.com/list/%s" % list
listing = []
ID = [] # IMDB_ID or thetvdb ID
if browser.open(url_search):
data = browser.content
for line in re.findall('<div class="info">(.*?)</div>', data, re.S):
items = re.search('/title/(.*?)/(.*?)>(.*?)<', line)
year = re.search('<span class="year_type">(.*?)<', line)
ID.append(items.group(1))
listing.append(items.group(3).replace(''', "'") + ' ' + year.group(1))
else:
print '[script.subscription.pulsar] %s' % browser.status
settings.dialog.notification('Pulsar List integration', browser.status, settings.icon, 5000)
subscription.integration(listing, ID, 'MOVIE', settings.movie_folder)
else:
settings.dialog.ok('Pulsar IMDB List', 'Empty List! Nothing added.')