def movie(self, imdb, title, year): try: langMap = {'hi':'hindi', 'ta':'tamil', 'te':'telugu', 'ml':'malayalam', 'kn':'kannada', 'bn':'bengali', 'mr':'marathi', 'pa':'punjabi'} lang = 'http://www.imdb.com/title/%s/' % imdb lang = client.request(lang) lang = re.findall('href\s*=\s*[\'|\"](.+?)[\'|\"]', lang) lang = [i for i in lang if 'primary_language' in i] lang = [urlparse.parse_qs(urlparse.urlparse(i).query) for i in lang] lang = [i['primary_language'] for i in lang if 'primary_language' in i] lang = langMap[lang[0][0]] q = self.search_link % (lang, urllib.quote_plus(title)) q = urlparse.urljoin(self.base_link, q) t = cleantitle.get(title) r = self.request(q) r = client.parseDOM(r, 'li') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'h3'), client.parseDOM(i, 'div', attrs = {'class': 'info'})) for i in r] r = [(i[0][0], i[1][0], i[2][0]) for i in r if i[0] and i[1] and i[2]] r = [(re.findall('(\d+)', i[0]), i[1], re.findall('(\d{4})', i[2])) for i in r] r = [(i[0][0], i[1], i[2][0]) for i in r if i[0] and i[2]] r = [i[0] for i in r if t == cleantitle.get(i[1]) and year == i[2]][0] url = str(r) return url except: return
def __search(self, search_link, imdb, title): try: query = search_link % (urllib.quote_plus(cleantitle.query(title))) query = urlparse.urljoin(self.base_link, query) t = cleantitle.get(title) r = client.request(query) r = client.parseDOM(r, 'div', attrs={'class': 'big-list'}) r = client.parseDOM(r, 'table', attrs={'class': 'row'}) r = client.parseDOM(r, 'td', attrs={'class': 'list-name'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [i[0] for i in r if t == cleantitle.get(i[1])][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') r = client.request(urlparse.urljoin(self.base_link, url)) r = client.parseDOM(r, 'a', attrs={'href': '[^\'"]+/tt\d+[^\'"]+'}, ret='href') r = [re.findall('.+?(tt\d+).*?', i) for i in r] r = [i[0] for i in r if len(i) > 0] return url if imdb in r else None except: return
def movie(self, imdb, title, year): try: if debrid.status() == False: raise Exception() t = cleantitle.get(title) headers = {'X-Requested-With': 'XMLHttpRequest'} query = self.search_link + urllib.quote_plus(title) query = urlparse.urljoin(self.base_link, query) r = client.request(query, headers=headers) r = json.loads(r) r = [ i for i in r if 'category' in i and 'movie' in i['category'].lower() ] r = [(i['url'], i['label']) for i in r if 'label' in i and 'url' in i] r = [(i[0], re.findall('(.+?) \((\d{4})', i[1])) for i in r] r = [(i[0], i[1][0][0], i[1][0][1]) for i in r if len(i[1]) > 0] r = [ i[0] for i in r if t == cleantitle.get(i[1]) and year == i[2] ][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def movie(self, imdb, title, year): try: t = cleantitle.get(title) q = '/search/%s.html' % (urllib.quote_plus( cleantitle.query(title))) q = urlparse.urljoin(self.base_link, q) for i in range(3): r = client.request(q) if not r == None: break r = client.parseDOM(r, 'div', attrs={'class': 'ml-item'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title')) for i in r] r = [(i[0][0], i[1][0]) for i in r if i[0] and i[1]] r = [i[0] for i in r if t == cleantitle.get(i[1])][:2] r = [(i, re.findall('(\d+)', i)[-1]) for i in r] for i in r: try: y, q = cache.get(self.ymovies_info, 9000, i[1]) if not y == year: raise Exception() return urlparse.urlparse(i[0]).path except: pass except: return
def __search(self, title): try: r = {'keyword': cleantitle.getsearch(title)} r = urllib.urlencode(r) r = client.request(urlparse.urljoin(self.base_link, self.search_link), post=r) t = cleantitle.get(title) r = json.loads(r) r = [(i['link'], re.sub('<.+?>|</.+?>', '', i['title'])) for i in r if 'title' in i and 'link' in i] r = [(i[0], i[1], re.findall('(.+?)\s*Movie \d+:.+?$', i[1], re.DOTALL)) for i in r] r = [(i[0], i[2][0] if len(i[2]) > 0 else i[1]) for i in r] r = [i[0] for i in r if t == cleantitle.get(i[1])][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def __search(self, title, year): try: r = client.request(self.base_link) r = re.findall('sL10n\s*=\s*({.*?});', r)[0] r = json.loads(r)['nonce'] query = self.search_link % (urllib.quote_plus(cleantitle.query(title)), r) query = urlparse.urljoin(self.base_link, query) t = cleantitle.get(title) y = ['%s' % str(year), '%s' % str(int(year) + 1), '%s' % str(int(year) - 1), '0'] r = client.request(query) r = json.loads(r) r = [(i, r[i].get('url', ''), r[i].get('title', ''), r[i].get('extra', {}).get('names', ''), r[i].get('extra', {}).get('date', '0')) for i in r] r = [(i[0], i[1], client.replaceHTMLCodes(i[2]), client.replaceHTMLCodes(i[3]), i[4]) for i in r] r = [i[1] for i in r if t == cleantitle.get(i[2]) or t == cleantitle.get(i[3]) and i[4] in y][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) t = cleantitle.get(data['tvshowtitle']) year = re.findall('(\d{4})', premiered)[0] years = [str(year), str(int(year) + 1), str(int(year) - 1)] season = '%01d' % int(season) episode = '%01d' % int(episode) q = self.search_link_2 % (urllib.quote_plus( '%s - Season %s' % (data['tvshowtitle'], season))) q = urlparse.urljoin(self.base_link, q) h = {'X-Requested-With': 'XMLHttpRequest'} u = urlparse.urljoin(self.base_link, self.search_link) p = urllib.urlencode( {'keyword': '%s - Season %s' % (data['tvshowtitle'], season)}) r = self.request(u, headers=h, post=p)[0] try: r = json.loads(r) except: r = None if r == None: r = self.request(q, headers=None, post=None)[0] r = client.parseDOM(r, 'div', attrs={'class': 'ml-item'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title')) for i in r] r = [(i[0][0], i[1][0]) for i in r if i[0] and i[1]] else: r = r['content'] r = zip( client.parseDOM(r, 'a', ret='href', attrs={'class': 'ss-title'}), client.parseDOM(r, 'a', attrs={'class': 'ss-title'})) r = [(i[0], re.findall('(.+?) - season (\d+)$', i[1].lower())) for i in r] r = [(i[0], i[1][0][0], i[1][0][1]) for i in r if len(i[1]) > 0] r = [i for i in r if t == cleantitle.get(i[1])] r = [i[0] for i in r if season == '%01d' % int(i[2])][:2] r = [(i, re.findall('(\d+)', i)[-1]) for i in r] for i in r: try: y, q = cache.get(self.onemovies_info, 9000, i[1]) if not y in years: raise Exception() return urlparse.urlparse( i[0]).path + '?episode=%01d' % int(episode) except: pass except: return
def __search(self, title, year, season='0', episode=False): try: query = self.search_link % (urllib.quote_plus(cleantitle.query(title))) query = urlparse.urljoin(self.base_link, query) t = cleantitle.get(title) y = ['%s' % str(year), '%s' % str(int(year) + 1), '%s' % str(int(year) - 1), '0'] r = client.request(query) r = client.parseDOM(r, 'ul', attrs={'class': 'products row'}) r = client.parseDOM(r, 'div', attrs={'class': 'box-product clearfix'}) r = client.parseDOM(r, 'h3', attrs={'class': 'title-product'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0].lower()) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [(i[0], i[1], re.findall('(.+?) \(*(\d{4})', i[1])) for i in r] r = [(i[0], i[2][0][0] if len(i[2]) > 0 else i[1], i[2][0][1] if len(i[2]) > 0 else '0') for i in r] r = [(i[0], i[1], i[2], re.findall('(.+?)\s+(?:staf+el|s)\s+(\d+)', i[1])) for i in r] r = [(i[0], i[3][0][0] if len(i[3]) > 0 else i[1], i[2], i[3][0][1] if len(i[3]) > 0 else '0') for i in r] r = [(i[0], i[1].replace(' hd', ''), i[2], i[3]) for i in r] r = [i[0] for i in r if t == cleantitle.get(i[1]) and i[2] in y and int(i[3]) == int(season)][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') url = url.replace('-info', '-stream') if episode: url = urlparse.urlparse(url).path + '?episode=%s' % int(episode) return url except: return
def movie(self, imdb, title, year): try: query = self.search_link % (urllib.quote_plus(title)) query = urlparse.urljoin(self.base_link, query) t = cleantitle.get(title) r = client.request(query) r = client.parseDOM(r, 'div', attrs={'class': 'cell_container'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title')) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [(i[0], re.findall('(.+?) \((\d{4})', i[1])) for i in r] r = [(i[0], i[1][0][0], i[1][0][1]) for i in r if len(i[1]) > 0] r = [ i[0] for i in r if t == cleantitle.get(i[1]) and year == i[2] ][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: data = urlparse.parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) t = cleantitle.get(data['tvshowtitle']) title = data['tvshowtitle'] season = '%01d' % int(season) episode = '%01d' % int(episode) year = re.findall('(\d{4})', premiered)[0] years = [str(year), str(int(year) + 1), str(int(year) - 1)] r = cache.get(self.ymovies_info_season, 720, title, season) r = [(i[0], re.findall('(.+?)\s+(?:-|)\s+season\s+(\d+)$', i[1].lower())) for i in r] r = [(i[0], i[1][0][0], i[1][0][1]) for i in r if i[1]] r = [ i[0] for i in r if t == cleantitle.get(i[1]) and season == '%01d' % int(i[2]) ][:2] r = [(i, re.findall('(\d+)', i)[-1]) for i in r] for i in r: try: y, q = cache.get(self.ymovies_info, 9000, i[1]) if not y == year: raise Exception() return urlparse.urlparse( i[0]).path + '?episode=%01d' % int(episode) except: pass except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return url = urlparse.urljoin(self.base_link, url) result = proxy.request(url, 'tv_episode_item') result = client.parseDOM(result, 'div', attrs={'class': 'tv_episode_item'}) title = cleantitle.get(title) premiered = re.compile('(\d{4})-(\d{2})-(\d{2})').findall( premiered)[0] premiered = '%s %01d %s' % (premiered[1].replace( '01', 'January').replace('02', 'February').replace( '03', 'March').replace('04', 'April').replace( '05', 'May').replace('06', 'June').replace( '07', 'July').replace('08', 'August').replace( '09', 'September').replace('10', 'October').replace( '11', 'November').replace( '12', 'December'), int( premiered[2]), premiered[0]) result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'span', attrs={'class': 'tv_episode_name'}), client.parseDOM(i, 'span', attrs={'class': 'tv_num_versions'})) for i in result] result = [ (i[0], i[1][0], i[2]) for i in result if len(i[1]) > 0 ] + [(i[0], None, i[2]) for i in result if len(i[1]) == 0] result = [ (i[0], i[1], i[2][0]) for i in result if len(i[2]) > 0 ] + [(i[0], i[1], None) for i in result if len(i[2]) == 0] result = [(i[0][0], i[1], i[2]) for i in result if len(i[0]) > 0] url = [ i for i in result if title == cleantitle.get(i[1]) and premiered == i[2] ][:1] if len(url) == 0: url = [i for i in result if premiered == i[2]] if len(url) == 0 or len(url) > 1: url = [ i for i in result if 'season-%01d-episode-%01d' % (int(season), int(episode)) in i[0] ] url = url[0][0] url = proxy.parse(url) url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def movie(self, imdb, title, year): try: t = cleantitle.get(title) y = [ '(%s)' % str(year), '(%s)' % str(int(year) + 1), '(%s)' % str(int(year) - 1) ] q = self.search_link % (urllib.quote_plus(cleantitle.query(title)), str(int(year) - 1), str(int(year) + 1)) q = urlparse.urljoin(self.base_link, q) r = proxy.request(q, 'movie_table') r = client.parseDOM(r, 'div', attrs={'class': 'movie_table'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'h1')) for i in r] r = [(i[0][0], i[1][0]) for i in r if i[0] and i[1]] r = [(i[0], client.parseDOM(i[1], 'a')) for i in r] r = [(i[0], i[1][0]) for i in r if i[1]] r = [i for i in r if any(x in i[1] for x in y)] r = [(proxy.parse(i[0]), i[1]) for i in r] match = [ i[0] for i in r if t == cleantitle.get(i[1]) and '(%s)' % str(year) in i[1] ] match2 = [i[0] for i in r] match2 = [x for y, x in enumerate(match2) if x not in match2[:y]] if match2 == []: return for i in match2[:5]: try: if match: url = match[0] break r = proxy.request(urlparse.urljoin(self.base_link, i), 'movie25') r = re.findall('(tt\d+)', r) if imdb in r: url = i break except: pass url = urlparse.urljoin(self.base_link, url) url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: pass
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: query = self.tvsearch_link % urllib.quote_plus( cleantitle.query(tvshowtitle)) query = urlparse.urljoin(self.base_link, query) result = str(proxy.request(query, 'item')) if 'page=2' in result or 'page%3D2' in result: result += str(proxy.request(query + '&page=2', 'item')) result = client.parseDOM(result, 'div', attrs={'class': 'item'}) tvshowtitle = 'watch' + cleantitle.get(tvshowtitle) years = [ '(%s)' % str(year), '(%s)' % str(int(year) + 1), '(%s)' % str(int(year) - 1) ] result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title')) for i in result] result = [(i[0][0], i[1][0]) for i in result if len(i[0]) > 0 and len(i[1]) > 0] result = [i for i in result if any(x in i[1] for x in years)] r = [(proxy.parse(i[0]), i[1]) for i in result] match = [ i[0] for i in r if tvshowtitle == cleantitle.get(i[1]) and '(%s)' % str(year) in i[1] ] match2 = [i[0] for i in r] match2 = [x for y, x in enumerate(match2) if x not in match2[:y]] if match2 == []: return for i in match2[:5]: try: if len(match) > 0: url = match[0] break r = proxy.request(urlparse.urljoin(self.base_link, i), 'tv_episode_item') r = re.findall('(tt\d+)', r) if imdb in r: url = i break except: pass url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def movie(self, imdb, title, year): try: q = self.search_link_2.decode('base64') % urllib.quote_plus(title) r = client.request(q) if r == None: r = client.request(q) if r == None: r = client.request(q) if r == None: r = client.request(q) r = json.loads(r)['results'] r = [(i['url'], i['titleNoFormatting']) for i in r] r = [(i[0], re.findall('(?:^Watch |)(.+? \(\d{4}\))', i[1])) for i in r] r = [(urlparse.urljoin(self.base_link, i[0]), i[1][0]) for i in r if i[1]] t = cleantitle.get(title) years = [ '(%s)' % str(year), '(%s)' % str(int(year) + 1), '(%s)' % str(int(year) - 1) ] r = [i for i in r if any(x in i[1] for x in years)] match = [ i[0] for i in r if t == cleantitle.get(i[1]) and '(%s)' % str(year) in i[1] ] match2 = [i[0] for i in r] match2 = [x for y, x in enumerate(match2) if x not in match2[:y]] if match2 == []: return for i in match2[:5]: try: if len(match) > 0: url = match[0] break r = proxy.request(urlparse.urljoin(self.base_link, i), 'ovie') r = re.findall('(tt\d+)', r) if imdb in r: url = i break except: pass url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: pass
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: t = cleantitle.get(tvshowtitle) j_c = self.__get_json("series") j = [i['id'] for i in j_c if t == cleantitle.get(i["series"])] if len(j) == 0: t = cleantitle.get(cleantitle.local(tvshowtitle, imdb, 'de-DE')) j = [i['id'] for i in j_c if t == cleantitle.get(i["series"])] return 'series/%s/' % j[0] except: return
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: query = base64.b64decode(self.search_link) % urllib.quote_plus( cleantitle.query(tvshowtitle)) result = self.request(query) tvshowtitle = cleantitle.get(tvshowtitle) years = [ '%s' % str(year), '%s' % str(int(year) + 1), '%s' % str(int(year) - 1) ] result = [ i for i in result if any(x in str(i['year']) for x in years) ] match = [ i['href'] for i in result if tvshowtitle == cleantitle.get(i['name']) ] match = [ i['href'] for i in result if tvshowtitle == cleantitle.get(i['name']) and str(year) == str(i['year']) ] match2 = [i['href'] for i in result] match2 = [x for y, x in enumerate(match2) if x not in match2[:y]] if match2 == []: return for i in match2[:5]: try: if len(match) > 0: url = match[0] break if imdb in str(self.request(i)[0]['imdb']): url = i break except: pass url = '/' + url.split('/json/')[-1] url = url.encode('utf-8') return url except: return
def movie(self, imdb, title, year): try: t = cleantitle.get(title) y = ['%s' % str(year), '%s' % str(int(year)+1), '%s' % str(int(year)-1), '0'] q = self.search_link % urllib.quote_plus(cleantitle.query(title)) q = urlparse.urljoin(self.base_link, q) r = proxy.request(q, 'flag') r = client.parseDOM(r, 'TR', attrs = {'id': 'coverPreview.+?'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a'), client.parseDOM(i, 'div', attrs = {'style': '.+?'}), client.parseDOM(i, 'img', ret='src')) for i in r] r = [(i[0][0].strip(), i[1][0].strip(), i[2], i[3]) for i in r if i[0] and i[1] and i[3]] r = [(i[0], i[1], [x for x in i[2] if x.isdigit() and len(x) == 4], i[3]) for i in r] r = [(i[0], i[1], i[2][0] if i[2] else '0', i[3]) for i in r] r = [i for i in r if any('us_flag_' in x for x in i[3])] r = [(i[0], i[1], i[2], [re.findall('(\d+)', x) for x in i[3] if 'smileys' in x]) for i in r] r = [(i[0], i[1], i[2], [x[0] for x in i[3] if x]) for i in r] r = [(i[0], i[1], i[2], int(i[3][0]) if i[3] else 0) for i in r] r = sorted(r, key=lambda x: x[3])[::-1] r = [(i[0], i[1], i[2], re.findall('\((.+?)\)$', i[1])) for i in r] r = [(i[0], i[1], i[2]) for i in r if not i[3]] r = [i for i in r if i[2] in y] r = [(proxy.parse(i[0]), i[1], i[2]) for i in r] match = [i[0] for i in r if t == cleantitle.get(i[1]) and year == i[2]] match2 = [i[0] for i in r] match2 = [x for y,x in enumerate(match2) if x not in match2[:y]] if match2 == []: return for i in match2[:5]: try: if match: url = match[0] ; break r = proxy.request(urlparse.urljoin(self.base_link, i), 'tablemoviesindex2') r = re.findall('(tt\d+)', r) if imdb in r: url = i ; break except: pass url = urlparse.urljoin(self.base_link, url) url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def __search(self, title, type, year, season=0, episode=False): try: query = self.search_link % ( type, year, urllib.quote_plus(cleantitle.query(title))) query = urlparse.urljoin(self.base_link, query) t = cleantitle.get(title) r = client.request(query) r = client.parseDOM(r, 'div', attrs={'class': 'ml-items'}) r = client.parseDOM(r, 'div', attrs={'class': 'ml-item'}) r = [(client.parseDOM(i, 'a', attrs={'class': 'ml-name'}, ret='href'), client.parseDOM(i, 'a', attrs={'class': 'ml-name'})) for i in r] r = [(i[0][0], re.sub('<.+?>|</.+?>', '', i[1][0]).strip()) for i in r if len(i[0]) > 0 and len(i[1]) > 0] r = [(i[0], i[1], re.findall('(.+?)\s+(?:staf+el|s)\s+(\d+)', i[1].lower())) for i in r] r = [(i[0], i[2][0][0] if len(i[2]) > 0 else i[1], i[2][0][1] if len(i[2]) > 0 else '0') for i in r] r = [ i[0] for i in r if t == cleantitle.get(i[1]) and int(i[2]) == int(season) ][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') if episode: query = urlparse.urljoin(self.base_link, url) r = client.request(query) r = client.parseDOM(r, 'div', attrs={'class': 'season-list'}) r = client.parseDOM(r, 'li') r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0]) for i in r if len(i[1]) > 0 and int(i[1][0]) == int(episode)] url = re.findall('(?://.+?|)(/.+)', r[0][0])[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def movie(self, imdb, title, year): try: t = cleantitle.get(title) q = self.search_link_2 % (urllib.quote_plus( cleantitle.query(title))) q = urlparse.urljoin(self.base_link, q) h = {'X-Requested-With': 'XMLHttpRequest'} u = urlparse.urljoin(self.base_link, self.search_link) p = urllib.urlencode({'keyword': title}) r = self.request(u, headers=h, post=p)[0] try: r = json.loads(r) except: r = None if r == None: r = self.request(q, headers=None, post=None)[0] r = client.parseDOM(r, 'div', attrs={'class': 'ml-item'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title')) for i in r] r = [(i[0][0], i[1][0]) for i in r if i[0] and i[1]] else: r = r['content'] r = zip( client.parseDOM(r, 'a', ret='href', attrs={'class': 'ss-title'}), client.parseDOM(r, 'a', attrs={'class': 'ss-title'})) r = [i[0] for i in r if cleantitle.get(t) == cleantitle.get(i[1])][:2] r = [(i, re.findall('(\d+)', i)[-1]) for i in r] for i in r: try: y, q = cache.get(self.onemovies_info, 9000, i[1]) if not y == year: raise Exception() return urlparse.urlparse(i[0]).path except: pass except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return url = urlparse.urljoin(self.base_link, url) result = proxy.request(url, 'tv_episode_item') result = client.parseDOM(result, 'div', attrs={'class': 'tv_episode_item'}) title = cleantitle.get(title) result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'span', attrs={'class': 'tv_episode_name'}), re.compile('(\d{4}-\d{2}-\d{2})').findall(i)) for i in result] result = [ (i[0], i[1][0], i[2]) for i in result if len(i[1]) > 0 ] + [(i[0], None, i[2]) for i in result if len(i[1]) == 0] result = [ (i[0], i[1], i[2][0]) for i in result if len(i[2]) > 0 ] + [(i[0], i[1], None) for i in result if len(i[2]) == 0] result = [(i[0][0], i[1], i[2]) for i in result if len(i[0]) > 0] url = [ i for i in result if title == cleantitle.get(i[1]) and premiered == i[2] ][:1] if len(url) == 0: url = [i for i in result if premiered == i[2]] if len(url) == 0 or len(url) > 1: url = [ i for i in result if 'season-%01d-episode-%01d' % (int(season), int(episode)) in i[0] ] url = client.replaceHTMLCodes(url[0][0]) url = proxy.parse(url) url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def __search(self, imdb, title, year): try: query = self.search_link % (urllib.quote_plus( cleantitle.query(title))) query = urlparse.urljoin(self.base_link, query) t = cleantitle.get(title) y = [ '%s' % str(year), '%s' % str(int(year) + 1), '%s' % str(int(year) - 1), '0' ] r = client.request(query) r = client.parseDOM(r, 'div', attrs={'class': 'main-area'}) r = client.parseDOM(r, 'li') r = client.parseDOM(r, 'div', attrs={'class': 'table-ui1'}) r = [(client.parseDOM(i, 'a', attrs={'title': ''}, ret='href'), client.parseDOM(i, 'a', attrs={'title': ''}), client.parseDOM(i, 'a', attrs={'href': '[^\'"]+/tt\d+[^\'"]+'}, ret='href')) for i in r] r = [(i[0][0], i[1][0].lower(), re.findall('.+?(tt\d+).*?', i[2][0])) for i in r if len(i[0]) > 0 and len(i[1]) > 0 and len(i[2]) > 0] r = [(i[0], i[1], i[2][0]) for i in r if len(i[2]) > 0] r = [(i[0], i[1], re.findall('(.+?) \((\d{4})\)?', i[1]), i[2]) for i in r] r = [(i[0], i[2][0][0] if len(i[2]) > 0 else i[1], i[2][0][1] if len(i[2]) > 0 else '0', i[3]) for i in r] r = [ i[0] for i in r if t == cleantitle.get(i[1]) and i[2] in y and i[3] == imdb ][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def movie(self, imdb, title, year): try: url = '%s/%s-%s/' % (self.base_link, cleantitle.geturl(title), year) url = client.request(url, output='geturl') if url == None: raise Exception() url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: pass try: t = cleantitle.get(title) q = '%s %s' % (title, year) q = self.search_link.decode('base64') % urllib.quote_plus(q) r = client.request(q, error=True) r = json.loads(r)['results'] r = [(i['url'], i['titleNoFormatting']) for i in r] r = [(i[0], re.findall('(?:^Watch Movie |^Watch |)(.+?)\((\d{4})', i[1])) for i in r] r = [(i[0], i[1][0][0], i[1][0][1]) for i in r if i[1]] r = [(urllib.unquote_plus(i[0]), i[1], i[2]) for i in r] r = [(urlparse.urlparse(i[0]).path, i[1], i[2]) for i in r] r = [i for i in r if t == cleantitle.get(i[1]) and year == i[2]] r = re.sub('/watch-movie-|-\d+$', '/', r[0][0].strip()) url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: pass
def movie(self, imdb, title, year): try: if (self.user == '' or self.password == ''): raise Exception() t = cleantitle.get(title) h = {'X-Requested-With': 'XMLHttpRequest'} u = urlparse.urljoin(self.base_link, self.search_link) p = { 'q': title.rsplit(':', 1)[0], 'limit': '10', 'timestamp': int(time.time() * 1000), 'verifiedCheck': '' } p = urllib.urlencode(p) r = client.request(u, post=p, headers=h) r = json.loads(r) r = [ i for i in r if i['meta'].strip().split()[0].lower() == 'movie' ] r = [i['permalink'] for i in r if t == cleantitle.get(i['title'])][:2] r = [(i, urlparse.urljoin(self.base_link, i)) for i in r] r = [(i[0], client.request(i[1])) for i in r] r = [(i[0], i[1]) for i in r if not i[1] == None] r = [(i[0], re.sub('\s|<.+?>|</.+?>', '', i[1])) for i in r] r = [(i[0], re.findall('eleased:(\d{4})', i[1])) for i in r] r = [(i[0], i[1][0]) for i in r if i[1]] r = [i for i in r if year in i[1]] r = r[0][0] url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: query = self.search_tv_link % (urllib.quote_plus(tvshowtitle)) query = urlparse.urljoin(self.base_link, query) r = client.request(query, headers={'X-Requested-With': 'XMLHttpRequest'}) r = json.loads(r) t = cleantitle.get(tvshowtitle) r = [(i['slug'], i['title'], i['year']) for i in r] r = [ i[0] for i in r if t == cleantitle.get(i[1]) and year == str(i[2]) ][0] url = r.encode('utf-8') return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return result = self.request(url) result = result[0]['episodes'].values() for i, v in enumerate(result): try: result[i] = v.values() except: pass result = [i for i in result if type(i) == list] result = sum(result, []) result = [i for i in result if i['hasLinks'] == True] title = cleantitle.get(title) premiered = re.compile('(\d{4})-(\d{2})-(\d{2})').findall( premiered)[0] premiered = '%s/%s/%s' % (premiered[2], premiered[1], premiered[0]) url = [ i for i in result if title == cleantitle.get(i['name']) and premiered == i['release'] ][:1] if len(url) == 0: url = [i for i in result if premiered == i['release']] if len(url) == 0 or len(url) > 1: url = [ i for i in result if '_s%01d_e%01d' % (int(season), int(episode)) in i['url'] ] url = '/' + url[0]['url'].split('/json/')[-1] url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: t = cleantitle.get(tvshowtitle) q = '%s %s' % (tvshowtitle, year) q = self.search_link.decode('base64') % urllib.quote_plus(q) r = client.request(q) r = json.loads(r)['results'] r = [(i['url'], i['titleNoFormatting']) for i in r] r = [(i[0], re.findall('(?:^Watch Movie |^Watch |)(.+?)$', i[1])) for i in r] r = [(i[0], i[1][0].rsplit('TV Series')[0].strip('(')) for i in r if i[1]] r = [(urllib.unquote_plus(i[0]), i[1]) for i in r] r = [(urlparse.urlparse(i[0]).path, i[1]) for i in r] r = [i for i in r if t == cleantitle.get(i[1])] r = urlparse.urljoin(self.base_link, r[0][0].strip()) if '/watch-movie-' in r: r = re.sub('/watch-movie-|-\d+$', '/', r) y = re.findall('(\d{4})', r) if y: y = y[0] else: y = client.request(r) y = re.findall('(?:D|d)ate\s*:\s*(\d{4})', y)[0] if not year == y: raise Exception() url = re.findall('(?://.+?|)(/.+)', r)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def tvshow(self, imdb, tvdb, tvshowtitle, year): try: t = cleantitle.get(tvshowtitle) q = urllib.quote_plus(cleantitle.query(tvshowtitle)) p = urllib.urlencode({'term': q}) h = {'X-Requested-With': 'XMLHttpRequest'} r = client.request(self.search_link, post=p, headers=h) try: r = json.loads(r) except: r = None if r: r = [(i['seo_url'], i['value'], i['label']) for i in r if 'value' in i and 'label' in i and 'seo_url' in i] else: r = proxy.request(self.search_link_2 % q, '/search/') r = client.parseDOM(r, 'div', attrs={'valign': '.+?'}) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title'), client.parseDOM(i, 'a')) for i in r] r = [(i[0][0], i[1][0], i[2][0]) for i in r if i[0] and i[1] and i[2]] r = [(i[0], i[1], re.findall('(\d{4})', i[2])) for i in r] r = [(i[0], i[1], i[2][-1]) for i in r if i[2]] r = [i for i in r if t == cleantitle.get(i[1]) and year == i[2]] url = r[0][0] url = proxy.parse(url) url = url.strip('/').split('/')[-1] url = url.encode('utf-8') return url except: return
def episode(self, url, imdb, tvdb, title, premiered, season, episode): try: if url == None: return url = '%s/serie/%s' % (self.base_link, url) r = proxy.request(url, 'fa-link') r = client.parseDOM(r, 'li', attrs={'itemprop': 'episode'}) t = cleantitle.get(title) r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'span', attrs={'itemprop': 'name'}), re.compile('(\d{4}-\d{2}-\d{2})').findall(i)) for i in r] r = [(i[0], i[1][0].split(' ')[-1], i[2]) for i in r if i[1]] + [(i[0], None, i[2]) for i in r if not i[1]] r = [(i[0], i[1], i[2][0]) for i in r if i[2]] + [(i[0], i[1], None) for i in r if not i[2]] r = [(i[0][0], i[1], i[2]) for i in r if i[0]] url = [ i for i in r if t == cleantitle.get(i[1]) and premiered == i[2] ][:1] if not url: url = [i for i in r if t == cleantitle.get(i[1])] if len(url) > 1 or not url: url = [i for i in r if premiered == i[2]] if len(url) > 1 or not url: raise Exception() url = url[0][0] url = proxy.parse(url) url = re.findall('(?://.+?|)(/.+)', url)[0] url = client.replaceHTMLCodes(url) url = url.encode('utf-8') return url except: return
def onlinedizi_tvcache(self): try: result = client.request(self.base_link) result = client.parseDOM(result, 'ul', attrs = {'class': 'all-series-list.+?'})[0] result = client.parseDOM(result, 'li') result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a')) for i in result] result = [(i[0][-1], i[1][0]) for i in result if len(i[0]) > 0 and len(i[1]) > 0] result = [(re.compile('http.+?//.+?/diziler(/.+?/)').findall(i[0]), re.sub('&#\d*;','', i[1])) for i in result] result = [(i[0][0], cleantitle.get(i[1])) for i in result if len(i[0]) > 0] return result except: return
def dizigold_tvcache(self): try: result = client.request(self.base_link) result = client.parseDOM(result, 'div', attrs={'class': 'dizis'})[0] result = re.compile('href="(.+?)">(.+?)<').findall(result) result = [(re.sub('http.+?//.+?/', '/', i[0]), re.sub('&#\d*;', '', i[1])) for i in result] result = [(i[0], cleantitle.get(i[1])) for i in result] return result except: return