def ymovies_info_season(self, title, season, proxy_options=None):
        try:
            qs = []
            q = '%s Season %s' % (cleantitle.query(title), season)
            qs.append(q)
            q = cleantitle.query(title)
            qs.append(q)

            #print qs
            for qm in qs:
                try:
                    q = '/search/%s.html' % (urllib.quote_plus(qm))
                    q = urlparse.urljoin(self.base_link, q)
                    #print q
                    for i in range(3):
                        #r = client.request(q, IPv4=True)
                        r = proxies.request(q,
                                            IPv4=True,
                                            proxy_options=proxy_options,
                                            use_web_proxy=self.proxyrequired)
                        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]]
                    if not r == None and len(r) > 0: break
                except:
                    pass

            return r
        except:
            return
Ejemplo n.º 2
0
 def search(self, title, localtitle, year, search_type):
     try:
         url = self.do_search(cleantitle.query(title), title, localtitle,
                              year, search_type)
         if not url:
             url = self.do_search(cleantitle.query(localtitle), title,
                                  localtitle, year, search_type)
         return url
     except:
         return
Ejemplo n.º 3
0
    def searchShow(self, title, season, year):
        try:
            title = cleantitle.normalize(title)
            t = cleantitle.get(title)

            url = urlparse.urljoin(
                self.base_link, self.search_link % urllib.quote_plus(
                    cleantitle.query('%s Season %01d' %
                                     (title.replace('\'', '-'), int(season)))))
            r = client.request(url, timeout='10')
            r = client.parseDOM(r, 'h2', attrs={'class': 'tit'})
            if r:
                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('(.+?)\s+-\s+Season\s+(\d+)', 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 int(season) == int(i[2])
                ][0]
            else:
                url = urlparse.urljoin(
                    self.base_link, self.search_link % urllib.quote_plus(
                        cleantitle.query(
                            '%s %01d' %
                            (title.replace('\'', '-'), int(year)))))
                r = client.request(url, timeout='10')
                r = client.parseDOM(r, 'h2', attrs={'class': 'tit'})
                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)
            return url.encode('utf-8')
        except:
            return
Ejemplo n.º 4
0
    def get_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 Exception as e:
            control.log('Error yesmovies %s' % e)
            return
Ejemplo n.º 5
0
    def get_show(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 = client.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 = url.strip('/').split('/')[-1]
            url = url.encode('utf-8')

            return url
        except:
            return
Ejemplo n.º 6
0
	def get_movie(self, imdb, title, year, proxy_options=None, key=None, testing=False):
		try:
			variations = [title, title.replace('&','and')]
			
			for title in variations:
				try:
					t = cleantitle.get(title)

					q = '/search/%s.html' % (urllib.quote_plus(cleantitle.query(title)))
					print q
					q = urlparse.urljoin(self.base_link, q)
					print q

					for i in range(3):
						r = client.request(q, IPv4=True)
						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:
					pass
		except Exception as e:
			control.log('Error %s > get_movie %s' % (self.name, e))
			return
Ejemplo n.º 7
0
    def get_show(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(
                client.request(query)).decode('iso-8859-1').encode('utf-8')
            if 'page=2' in result:
                result += str(client.request(query + '&page=2')).decode(
                    'iso-8859-1').encode('utf-8')

            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)]

            try:
                result = [(urlparse.urlparse(i[0]).path, i[1]) for i in result]
            except:
                pass

            match = [
                i[0] for i in result
                if tvshowtitle == cleantitle.get(i[1]) and '(%s)' %
                str(year) in i[1]
            ]

            match2 = [i[0] 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
                    result = client.request(urlparse.urljoin(
                        self.base_link, i))
                    if imdb in str(result):
                        url = i
                        break
                except:
                    pass

            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 8
0
    def search(self, localtitle, year, search_type):
        try:
            simply_name = cleantitle.get(localtitle)

            query = self.search_link % urllib.quote_plus(
                cleantitle.query(localtitle))
            query = urlparse.urljoin(self.base_link, query)
            result = client.request(query)

            result = client.parseDOM(result,
                                     'div',
                                     attrs={'class': 'result-item'})
            for x in result:
                correct_type = client.parseDOM(x,
                                               'span',
                                               attrs={'class': search_type})
                correct_year = client.parseDOM(x,
                                               'span',
                                               attrs={'class':
                                                      'year'})[0] == year
                name = client.parseDOM(x, 'div', attrs={'class': 'title'})[0]
                url = client.parseDOM(name, 'a', ret='href')[0]
                name = cleantitle.get(client.parseDOM(name, 'a')[0])
                if (correct_type and correct_year and name == simply_name):
                    return url

        except:
            return
Ejemplo n.º 9
0
    def search(self, title, localtitle, year):
        try:
            titles = []
            title2 = title.split('.')[0]
            localtitle2 = localtitle.split('.')[0]
            titles.append(cleantitle.normalize(cleantitle.getsearch(title2)))
            titles.append(cleantitle.normalize(cleantitle.getsearch(localtitle2)))
            titles.append(title2)
            titles.append(localtitle2)
            for title in titles:
                try:
                    token = client.request("https://filmowakraina.tv/movies")
                    token = re.findall("""token:.*'(.*?)'""", token)[0]
                    url = self.search_link % (token, urllib.quote_plus(cleantitle.query(title)), 'movie')
                    content = client.request(url)
                    content = json.loads(content)
                    for item in content[u'items']:
                        if year in item[u'release_date']:
                            return item[u'link']
                except:
                    pass

        except Exception as e:
            print(str(e))
            return
Ejemplo n.º 10
0
    def get_movie(self, imdb, title, year):
        try:
            t = cleantitle.get(title)

            q = self.search_link % (urllib.quote_plus(cleantitle.query(title)))
            q = q.replace('+', '-')
            q = urlparse.urljoin(self.base_link, q)

            r = self.request(q)[0]
            r = client.parseDOM(r, 'div', attrs={'class': 'ml-item'})
            r = [(client.parseDOM(i, 'a', ret='href'),
                  client.parseDOM(i, 'a', ret='title'),
                  client.parseDOM(i, 'a', ret='data-url')) for i in r]
            r = [(i[0][0], i[1][0], i[2][0]) for i in r if i[0] and i[1]]
            #else:
            #    r = zip(client.parseDOM(r, 'a', ret='href', attrs = {'class': 'ss-title'}), client.parseDOM(r, 'a', attrs = {'class': 'ss-title'}))

            r = [(i[0], i[2]) for i in r
                 if cleantitle.get(t) == cleantitle.get(i[1])][:2]
            r = [(i[0], re.findall('(\d+)', i[1])[-1]) for i in r]

            for i in r:
                try:
                    y, q = cache.get(self.solar_info, 9000, i[1])
                    if not y == year: raise Exception()
                    return urlparse.urlparse(i[0]).path
                except:
                    pass

        except Exception as e:
            control.log('ERROR Solar %s' % e)
            return
Ejemplo n.º 11
0
    def movie(self, imdb, title, localtitle, aliases, year):
        try:
            url = self.search_link % (cleantitle.geturl(title), year)

            q = urlparse.urljoin(self.base_link, url)

            r = proxy.geturl(q)
            if not r == None: return url

            t = cleantitle.get(title)

            q = self.search_link_2 % urllib.quote_plus(cleantitle.query(title))
            q = urlparse.urljoin(self.base_link, q)

            r = client.request(q)

            r = zip(client.parseDOM(r, 'a', ret='href'),
                    client.parseDOM(r, 'a'))
            r = [(i[0], re.findall('(?:\'|\")(.+?)(?:\'|\")', i[1]))
                 for i in r]
            r = [(i[0], [re.findall('(.+?)\((\d{4})', x) for x in i[1]])
                 for i in r]
            r = [(i[0], [x[0] for x in i[1] if x]) 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 year == i[2]]

            url = re.findall('(?://.+?|)(/.+)', r[0])[0]
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 12
0
    def sezonlukdizi_tvcache(self):
        try:
            url = urlparse.urljoin(self.base_link, self.search_link)

            result = client.request(url, redirect=False)

            if not result:
                r = client.request(self.base_link)
                r = \
                    dom_parser.parse_dom(r, 'script',
                                         attrs={'type': 'text/javascript', 'src': re.compile('.*/js/dizi.*')},
                                         req='src')[0]
                url = urlparse.urljoin(self.base_link, r.attrs['src'])
                result = client.request(url)

            result = re.compile('{(.+?)}').findall(result)
            result = [(re.findall('u\s*:\s*(?:\'|\")(.+?)(?:\'|\")', i),
                       re.findall('d\s*:\s*(?:\'|\")(.+?)(?:\',|\")', i))
                      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 = [(re.compile('/diziler(/.+?)(?://|\.|$)').findall(i[0]),
                       re.sub('&#\d*;', '', i[1])) for i in result]
            result = [(i[0][0] + '/', cleantitle.query(self.lat2asc(i[1])))
                      for i in result if len(i[0]) > 0]

            return result
        except:
            return []
Ejemplo n.º 13
0
    def get_movie(self, imdb, title, year):
        try:
            t = cleantitle.get(title)

            q = self.search_link_2 % (urllib.quote_plus(cleantitle.query(title)))
            q = q.replace('+','-')
            q = urlparse.urljoin(self.base_link, q)


            r = self.request(q)[0]
            r = client.parseDOM(r, 'div', attrs = {'class': 'ml-item'})
            r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'a', ret='title'), client.parseDOM(i, 'a', ret='data-url')) for i in r]
            r = [(i[0][0], i[1][0], i[2][0]) for i in r if i[0] and i[1]]
            #else:
            #    r = zip(client.parseDOM(r, 'a', ret='href', attrs = {'class': 'ss-title'}), client.parseDOM(r, 'a', attrs = {'class': 'ss-title'}))

            r = [(i[0],i[2]) for i in r if cleantitle.get(t) == cleantitle.get(i[1])][:2]
            r = [(i[0], re.findall('(\d+)', i[1])[-1]) for i in r]

            for i in r:
                try:
                    y, q = cache.get(self.muchmovies_info, 9000, i[1])
                    if not y == year: raise Exception()
                    return urlparse.urlparse(i[0]).path
                except:
                    pass
        except:
            return
Ejemplo n.º 14
0
    def do_search(self, title, local_title, year, video_type):
        try:
            url = urlparse.urljoin(self.base_link, self.search_link)
            url = url % urllib.quote_plus(cleantitle.query(title))
            result = client.request(url)
            result = client.parseDOM(result, 'div', attrs={'class': 'item'})
            for row in result:
                row_type = client.parseDOM(row,
                                           'div',
                                           attrs={'class': 'typepost'})[0]
                if row_type != video_type:
                    continue
                names = client.parseDOM(row, 'span', attrs={'class': 'tt'})[0]
                names = names.split('/')
                year_found = client.parseDOM(row,
                                             'span',
                                             attrs={'class': 'year'})

                titles = [cleantitle.get(i) for i in [title, local_title]]

                if self.name_matches(names, titles,
                                     year) and (len(year_found) == 0
                                                or year_found[0] == year):
                    url = client.parseDOM(row, 'a', ret='href')[0]
                    return urlparse.urljoin(self.base_link, url)
        except:
            return
Ejemplo n.º 15
0
    def get_show(self, imdb, tvdb, tvshowtitle, year):
        try:
            list = cache.get(self.sezonlukdizi_tvcache, 120)
            url = [i[0] for i in list if cleantitle.query(tvshowtitle) == i[1]]

            if not url:
                t = cache.get(self.getImdbTitle, 900, imdb)
                url = [i[0] for i in list if cleantitle.query(t) == i[1]]

            url = urlparse.urljoin(self.base_link, url[0])
            url = urlparse.urlparse(url).path
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 16
0
    def get_movie(self, imdb, title, year):
        print("ALLtube originaltitle:%s" % title)
        print cleantitle.query(title)
        try:
            query = self.moviesearch_link % urllib.quote_plus(cleantitle.query2(title))
            query = urlparse.urljoin(self.base_link, query)
            control.log('ALLTUBE T URL %s' % query)
            result = client.source(query)
            result = json.loads(result)

            result = [i for i in result['suggestions'] if len(i) > 0]
            years = ['%s' % str(year), '%s' % str(int(year)+1), '%s' % str(int(year)-1)]
            result = [(i['data'].encode('utf8'),i['value'].encode('utf8')) for i in result]
            result = [i for i in result if cleantitle.movie(title) in cleantitle.movie(i[1])]
            result = [i[0] for i in result if any(x in i[1] for x in years)][0]
            print("ALLtube result :", result)

            try: url = re.compile('//.+?(/.+)').findall(result)[0]
            except: url = result
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            control.log('ALLTUBE URL %s' % url)
            return url
        except:
            try:
                query = self.moviesearch_link % cleantitle.query_quote(originaltitle)
                query = urlparse.urljoin(self.base_link, query)
                control.log('ALLTUBE T URL %s' % query)
                result = client.source(query)
                result = json.loads(result)

                result = [i for i in result['suggestions'] if len(i) > 0]
                years = ['%s' % str(year), '%s' % str(int(year)+1), '%s' % str(int(year)-1)]
                result = [(i['data'].encode('utf8'),i['value'].encode('utf8')) for i in result]
                print result
                result = [i for i in result if cleantitle.movie(originaltitle) in cleantitle.movie(i[1])]
                result = [i[0] for i in result if any(x in i[1] for x in years)][0]
                print("ALLtube result :", result)

                try: url = re.compile('//.+?(/.+)').findall(result)[0]
                except: url = result
                url = client.replaceHTMLCodes(url)
                url = url.encode('utf-8')
                control.log('ALLTUBE URL %s' % url)
                return url
            except:
                return
Ejemplo n.º 17
0
    def get_movie(self, imdb, title, year):
        try:
            # query = self.search_link % (urllib.quote_plus(cleantitle.query(title)), str(int(year)-1), str(int(year)+1))
            # query = urlparse.urljoin(self.base_link, query)

            query = self.search_link % urllib.quote_plus(cleantitle.query(title))
            query = urlparse.urljoin(self.base_link, query)

            result = str(self.request(query, "movie_table"))
            if "page=2" in result or "page%3D2" in result:
                result += str(self.request(query + "&page=2", "movie_table"))

            result = client.parseDOM(result, "div", attrs={"class": "movie_table"})

            title = cleantitle.get(title)
            years = ["(%s)" % str(year), "(%s)" % str(int(year) + 1), "(%s)" % str(int(year) - 1)]

            result = [(client.parseDOM(i, "a", ret="href"), client.parseDOM(i, "img", ret="alt")) 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)]

            try:
                result = [(urlparse.parse_qs(urlparse.urlparse(i[0]).query)["q"][0], i[1]) for i in result]
            except:
                pass
            try:
                result = [(urlparse.parse_qs(urlparse.urlparse(i[0]).query)["u"][0], i[1]) for i in result]
            except:
                pass
            try:
                result = [(urlparse.urlparse(i[0]).path, i[1]) for i in result]
            except:
                pass

            match = [i[0] for i in result if title == cleantitle.get(i[1]) and "(%s)" % str(year) in i[1]]

            match2 = [i[0] 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
                    result = self.request(urlparse.urljoin(self.base_link, i), "link_name")
                    if imdb in str(result):
                        url = i
                        break
                except:
                    pass

            url = client.replaceHTMLCodes(url)
            url = url.encode("utf-8")
            return url
        except:
            return
Ejemplo n.º 18
0
    def get_movie(self, imdb, title, year):
        try:
            t = cleantitle.get(title)

            query = '%s %s' % (title, year)
            query = base64.b64decode(self.search_link) % urllib.quote_plus(query)

            result = client.request(query)
            result = json.loads(result)['results']

            result = [(i['url'], i['titleNoFormatting']) for i in result]
            result = [(i[0], re.findall('(?:^Ver |)(.+?)(?: HD |)\((\d{4})', i[1])) for i in result]
            result = [(i[0], i[1][0][0], i[1][0][1]) for i in result if len(i[1]) > 0]

            r = [i for i in result if t == cleantitle.get(i[1]) and year == i[2]]

            if len(r) == 0:
                t = 'http://www.imdb.com/title/%s' % imdb
                t = client.request(t, headers={'Accept-Language':'es-ES'})
                t = client.parseDOM(t, 'title')[0]
                t = re.sub('(?:\(|\s)\d{4}.+', '', t).strip()
                t = cleantitle.get(t)

                r = [i for i in result if t == cleantitle.get(i[1]) and year == i[2]]

            try: url = re.findall('//.+?(/.+)', r[0][0])[0]
            except: url = r[0][0]
            try: url = re.findall('(/.+?/.+?/)', url)[0]
            except: pass
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')

            return url
        except:
            pass

        try:
            t = cleantitle.get(title)

            query = self.search3_link % urllib.quote_plus(cleantitle.query(title))
            query = urlparse.urljoin(self.base_link, query)

            result = client.request(query)
            result = re.sub(r'[^\x00-\x7F]+','', result)

            r = result.split('<li class=')
            r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'i'), re.findall('\((\d{4})\)', i)) for i in r]
            r = [(i[0][0], re.sub('\(|\)','', i[1][0]), 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] for i in r if t == cleantitle.get(i[1]) and year == i[2]][0]

            try: url = re.findall('//.+?(/.+)', r)[0]
            except: url = r
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')

            return url
        except:
            pass
Ejemplo n.º 19
0
 def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year):
     try:
         url = urlparse.urljoin(
             self.base_link, self.search_link %
             urllib.quote_plus(cleantitle.query(tvshowtitle)))
         self.tvshowtitle = tvshowtitle
         return url
     except:
         return
Ejemplo n.º 20
0
    def get_movie(self, imdb, title, year, proxy_options=None, key=None):
        try:
            if control.setting('Provider-%s' % name) == False:
                log('INFO', 'get_movie', 'Provider Disabled by User')
                return None

            variations = [title, title.replace('&', 'and')]

            for title in variations:
                try:
                    t = cleantitle.get(title)

                    q = self.api_search % (urllib.quote_plus(
                        cleantitle.query(title).replace(' ',
                                                        '-')), self.base_link)
                    #q = urlparse.urljoin(self.base_link, q)

                    #r = client.request(q, headers=self.headers, IPv4=True)
                    r = proxies.request(q,
                                        headers=self.headers,
                                        IPv4=True,
                                        proxy_options=proxy_options,
                                        use_web_proxy=self.proxyrequired)
                    #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'),
                          client.parseDOM(i, 'a', ret='data-url')) 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[2]) 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:
                            u = i[1]
                            if 'http' not in u:
                                u = urlparse.urljoin(self.base_link, u)
                            y, q, h = self.ymovies_info(u)
                            if 'http' not in h:
                                h = urlparse.urljoin(self.base_link, h)
                            #print '%s == %s' % (y, year)

                            if str(y).strip() != str(
                                    year).strip() or h == None:
                                raise Exception()
                            url = h
                            return [url, None]
                        except:
                            pass
                except:
                    pass
        except Exception as e:
            log('ERROR', 'get_movie', '%s: %s' % (title, e), dolog=self.init)
            return
Ejemplo n.º 21
0
 def get_movie(self, imdb, title, year):
     try:
         url = {'imdb': imdb, 'title': title, 'year': year}
         url = urllib.urlencode(url)
         if not url:
             t = cache.get(self.getImdbTitle, 900, imdb)
             url = [i[0] for i in list if cleantitle.query(t) == i[1]]
         return url
     except:
         return
Ejemplo n.º 22
0
    def get_show(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(client.request(query, 'item'))
            if 'page=2' in result or 'page%3D2' in result: result += str(client.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)]
            print "Resu", result

            r = []
            for i in result:
                u = i[0]
                try: u = urlparse.parse_qs(urlparse.urlparse(u).query)['u'][0]
                except: pass
                try: u = urlparse.parse_qs(urlparse.urlparse(u).query)['q'][0]
                except: pass
                r += [(u, i[1])]
            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
                    print "i",i
                    r = client.request(urlparse.urljoin(self.base_link, i), 'tv_episode_item')
                    print "r",imdb
                    print "r",r
                    if imdb in str(r):
                        url = i
                        break
                except:
                    pass

            url = re.findall('(?://.+?|)(/.+)', url)[0]
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            print "URL",url
            return url
        except:
            return
Ejemplo n.º 23
0
    def get_show(self, imdb, tvdb, tvshowtitle, year):
        try:
            key = urlparse.urljoin(self.base_link, self.key_link)
            key = client.request(key, 'searchform')
            key = client.parseDOM(key, 'input', ret='value', attrs = {'name': 'key'})[0]

            query = self.tvsearch_link % (urllib.quote_plus(cleantitle.query(tvshowtitle)), key)
            query = urlparse.urljoin(self.base_link, query)

            result = str(client.request(query, 'index_item'))
            if 'page=2' in result or 'page%3D2' in result: result += str(client.request(query + '&page=2', 'index_item'))

            result = client.parseDOM(result, 'div', attrs = {'class': 'index_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 = []
            for i in result:
                u = i[0]
                try: u = urlparse.parse_qs(urlparse.urlparse(u).query)['u'][0]
                except: pass
                try: u = urlparse.parse_qs(urlparse.urlparse(u).query)['q'][0]
                except: pass
                r += [(u, i[1])]

            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 = client.request(urlparse.urljoin(self.base_link, i), 'tv_episode_item')
                    if imdb in str(r): url = i ; break
                except:
                    pass

            url = re.findall('(?://.+?|)(/.+)', url)[0]
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 24
0
    def __search(self, imdb, titles, year):
        try:
            q = self.search_link % urllib.quote_plus(cleantitle.query(titles[0]))
            q = urlparse.urljoin(self.base_link, q)

            t = [cleantitle.get(i) for i in set(titles) if i]
            y = ['%s' % str(year), '%s' % str(int(year) + 1), '%s' % str(int(year) - 1), '0']

            r = client.request(q)

            r = dom_parser.parse_dom(r, 'tr', attrs={'id': re.compile('coverPreview.+?')})
            r = [(dom_parser.parse_dom(i, 'a', req='href'),
                  dom_parser.parse_dom(i, 'div', attrs={'style': re.compile('.+?')}),
                  dom_parser.parse_dom(i, 'img', req='src')) for i in r]
            r = [(i[0][0].attrs['href'].strip(), i[0][0].content.strip(), i[1], i[2]) for i in r if i[0] and i[2]]
            r = [(i[0], i[1], [x.content for x in i[2] if x.content.isdigit() and len(x.content) == 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.attrs['src'] for x in i[3])]
            r = [(i[0], i[1], i[2], [re.findall('(\d+)', x.attrs['src']) for x in i[3] if 'smileys' in x.attrs['src']])
                 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 = sorted(r, key=lambda i: int(i[2]), reverse=True)  # with year > no year

            r = [(client.replaceHTMLCodes(i[0]), i[1], i[2]) for i in r]

            match = [i[0] for i in r if cleantitle.get(i[1]) in t 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 = client.request(urlparse.urljoin(self.base_link, i))
                    r = re.findall('(tt\d+)', r)
                    if imdb in r: url = i; break
                except:
                    pass

            return source_utils.strip_domain(url)
        except:
            return
Ejemplo n.º 25
0
    def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year):
        try:
            query = self.search_link % urllib.quote_plus(cleantitle.query(tvshowtitle))
            result = client.request(query)
            # tvshowtitle = cleantitle.get(tvshowtitle)
            t = [tvshowtitle] + source_utils.aliases_to_array(aliases)
            t = [cleantitle.get(i) for i in set(t) if i]
            result = re.compile('itemprop="url"\s+href="([^"]+).*?itemprop="name"\s+class="serie-title">([^<]+)',
                                re.DOTALL).findall(result)
            for i in result:
                if cleantitle.get(cleantitle.normalize(i[1])) in t and year in i[1]: url = i[0]

            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 26
0
    def get_movie(self, imdb, title, year):
        try:
            #query = self.search_link % (urllib.quote_plus(cleantitle.query(title)), str(int(year)-1), str(int(year)+1))
            #query = urlparse.urljoin(self.base_link, query)

            query = self.search_link % urllib.quote_plus(cleantitle.query(title))
            query = urlparse.urljoin(self.base_link, query)

            result = str(self.request(query, 'movie_table'))
            if 'page=2' in result or 'page%3D2' in result: result += str(self.request(query + '&page=2', 'movie_table'))

            result = client.parseDOM(result, 'div', attrs = {'class': 'movie_table'})

            title = cleantitle.get(title)
            years = ['(%s)' % str(year), '(%s)' % str(int(year)+1), '(%s)' % str(int(year)-1)]

            result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'img', ret='alt')) 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)]

            try: result = [(urlparse.parse_qs(urlparse.urlparse(i[0]).query)['q'][0], i[1]) for i in result]
            except: pass
            try: result = [(urlparse.parse_qs(urlparse.urlparse(i[0]).query)['u'][0], i[1]) for i in result]
            except: pass
            try: result = [(urlparse.urlparse(i[0]).path, i[1]) for i in result]
            except: pass

            match = [i[0] for i in result if title == cleantitle.get(i[1]) and '(%s)' % str(year) in i[1]]

            match2 = [i[0] 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
                    result = self.request(urlparse.urljoin(self.base_link, i), 'link_name')
                    if imdb in str(result): url = i ; break
                except:
                    pass

            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 27
0
    def ymovies_info_season(self, title, season):
        try:
            q = '%s Season %s' % (cleantitle.query(title), season)
            q = '/search/%s.html' % (urllib.quote_plus(q))
            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]]

            return r
        except:
            return
Ejemplo n.º 28
0
    def get_movie(self, imdb, title, year, proxy_options=None, key=None):
        try:
            if control.setting('Provider-%s' % name) == False:
                log('INFO', 'get_movie', 'Provider Disabled by User')
                return None
            variations = [title, title.replace('&', 'and')]

            for title in variations:
                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, IPv4=True)
                        r = proxies.request(q,
                                            IPv4=True,
                                            proxy_options=proxy_options,
                                            use_web_proxy=self.proxyrequired)
                        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],
                                             proxy_options=proxy_options)
                            if not y == year: raise Exception()
                            return urlparse.urlparse(i[0]).path, ''
                        except:
                            pass
                except:
                    pass
        except Exception as e:
            log('ERROR', 'get_movie', '%s: %s' % (title, e), dolog=self.init)
            return
Ejemplo n.º 29
0
    def get_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)

            u = urlparse.urljoin(self.base_link, self.search_link)
            p = urllib.urlencode({'keyword': title})

            r = self.request(u, post=p, XHR=True)[0]

            try:
                r = json.loads(r)['content']
            except:
                r = None

            if r == None:
                r = self.request(q)[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 = 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
Ejemplo n.º 30
0
 def do_search(self, title, year, video_type):
     try:
         url = urlparse.urljoin(self.base_link, self.search_link)
         url = url % urllib.quote_plus(cleantitle.query(title))
         result = client.request(url)
         result = client.parseDOM(result, 'div', attrs={'class': 'item'})
         for row in result:
             row_type = client.parseDOM(row, 'div', attrs={'class': 'typepost'})[0]
             if row_type != video_type:
                 continue
             names = client.parseDOM(row, 'span', attrs={'class': 'tt'})[0]
             names = names.split('/')
             year_found = client.parseDOM(row, 'span', attrs={'class': 'year'})
             if self.name_matches(names, title, year) and (len(year_found) == 0 or year_found[0] == year):
                 url = client.parseDOM(row, 'a', ret='href')[0]
                 return urlparse.urljoin(self.base_link, url)
     except :
         return
Ejemplo n.º 31
0
    def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year):
        try:
            query = self.search % urllib.quote_plus(cleantitle.query(tvshowtitle))
            url = urlparse.urljoin(self.base_link, query)

            result = client.request(url)

            search_list = re.findall('<a href="(.+?\/serie\/.+?)" title="(.+?)"', result)

            for found in search_list:
                if tvshowtitle in found[1]:
                    url = found[0]
                    break

            return url

        except Exception:
            return
Ejemplo n.º 32
0
    def search(self, localtitle, year, search_type):
        try:
            url = urlparse.urljoin(self.base_link, self.search_link)
            r = client.request(url, redirect=False, post={'q': cleantitle.query(localtitle), 'sb': ''})
            r = client.parseDOM(r, 'div', attrs={'class': 'small-item'})

            local_simple = cleantitle.get(localtitle)
            for row in r:
                name_found = client.parseDOM(row, 'a')[1]
                year_found = name_found[name_found.find("(") + 1:name_found.find(")")]
                url = client.parseDOM(row, 'a', ret='href')[1]
                if not search_type in url:
                    continue

                if cleantitle.get(name_found) == local_simple and year_found == year:
                    return url
        except:
            return
Ejemplo n.º 33
0
    def get_show(self, imdb, tvdb, tvshowtitle, year):
        try:
            key = urlparse.urljoin(self.base_link, self.key_link)
            key = proxy.request(key, 'main_body')
            key = client.parseDOM(key, 'input', ret='value', attrs = {'name': 'key'})[0]

            query = self.tvsearch_link % (urllib.quote_plus(cleantitle.query(tvshowtitle)), key)
            query = urlparse.urljoin(self.base_link, query)

            result = str(proxy.request(query, 'main_body'))
            if 'page=2' in result or 'page%3D2' in result: result += str(proxy.request(query + '&page=2', 'main_body'))

            result = client.parseDOM(result, 'div', attrs = {'class': 'index_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), 'main_body')
                    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
Ejemplo n.º 34
0
    def search(self, title, localtitle, year, search_type):
        try:
            titles = []
            titles.append(
                cleantitle.normalize(cleantitle.getsearch(title + " 3d")))
            titles.append(
                cleantitle.normalize(cleantitle.getsearch(localtitle + " 3d")))
            cookies = client.request(self.base_link, output='cookie')
            cache.cache_insert('alltube_cookie', cookies)
            for title in titles:
                r = client.request(urlparse.urljoin(self.base_link,
                                                    self.search_link),
                                   post={'search': cleantitle.query(title)},
                                   headers={'Cookie': cookies})
                r = self.get_rows(r, search_type)

                for row in r:
                    url = client.parseDOM(row, 'a', ret='href')[0]
                    names_found = client.parseDOM(row, 'h3')[0]
                    if names_found.startswith(
                            'Zwiastun') and not title.startswith('Zwiastun'):
                        continue
                    names_found = names_found.encode('utf-8').split('/')
                    names_found = [
                        cleantitle.normalize(cleantitle.getsearch(i))
                        for i in names_found
                    ]
                    for name in names_found:
                        name = name.replace("  ", " ")
                        title = title.replace("  ", " ")
                        words = title.split(" ")
                        found_year = self.try_read_year(url)
                        if self.contains_all_wors(
                                name, words) and (not found_year
                                                  or found_year == year):
                            return url
                        else:
                            continue
                    continue
        except Exception, e:
            print e
            return
Ejemplo n.º 35
0
    def tvshow(self, imdb, tvdb, tvshowtitle, localtvshowtitle, aliases, year):
        try:
            t = cleantitle.get(tvshowtitle)

            q = urllib.quote_plus(cleantitle.query(tvshowtitle))
            p = urllib.urlencode({'term': q})

            r = client.request(self.search_link, post=p, XHR=True)
            try:
                r = json.loads(r)
            except:
                r = None
            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, 'tv shows')
                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:
            failure = traceback.format_exc()
            print('XWatchSeries - Exception: \n' + str(failure))
            return
Ejemplo n.º 36
0
    def sezonlukdizi_tvcache(self):
        try:
            url = urlparse.urljoin(self.base_link, self.search_link)

            result = client.request(url, redirect=False)

            if not result:
                r = client.request(self.base_link)
                r = client.parseDOM(r, 'script', attrs={'type':'text/javascript'}, ret='src')
                url = [s for s in r if '/js/dizi' in s][0]
                url = urlparse.urljoin(self.base_link, url)
                result = client.request(url)

            result = re.compile('{(.+?)}').findall(result)
            result = [(re.findall('u\s*:\s*(?:\'|\")(.+?)(?:\'|\")', i), re.findall('d\s*:\s*(?:\'|\")(.+?)(?:\',|\")', i)) 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 = [(re.compile('/diziler(/.+?)(?://|\.|$)').findall(i[0]), re.sub('&#\d*;','', i[1])) for i in result]
            result = [(i[0][0] + '/', cleantitle.query(i[1])) for i in result if len(i[0]) > 0]

            return result
        except:
            return
Ejemplo n.º 37
0
    def get_show(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 = client.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 = url.strip('/').split('/')[-1]
            url = url.encode('utf-8')

            return url
        except:
            return
Ejemplo n.º 38
0
    def get_show(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(client.request(query)).decode('iso-8859-1').encode('utf-8')
            if 'page=2' in result: result += str(client.request(query + '&page=2')).decode('iso-8859-1').encode('utf-8')

            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)]

            try: result = [(urlparse.urlparse(i[0]).path, i[1]) for i in result]
            except: pass

            match = [i[0] for i in result if tvshowtitle == cleantitle.get(i[1]) and '(%s)' % str(year) in i[1]]

            match2 = [i[0] 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
                    result = client.request(urlparse.urljoin(self.base_link, i))
                    if imdb in str(result): url = i ; break
                except:
                    pass

            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')
            return url
        except:
            return
Ejemplo n.º 39
0
    def search_ep(self, titles, season, episode):
        try:
            titles = list(titles)
            titles.sort()
            year = titles[0]
            for title in titles[1:]:
                try:
                    token = client.request("https://filmowakraina.tv/movies")
                    token = re.findall("""token:.*'(.*?)'""", token)[0]
                    url = self.search_link % (token, urllib.quote_plus(cleantitle.query(title)), 'series')
                    content = client.request(url)
                    content = json.loads(content)
                    for item in content[u'items']:
                        if year in item[u'release_date']:
                            test = [x for x in item[u'link'] if
                                    x[u'season'] == int(season) and x[u'episode'] == int(episode)]
                            return test
                except:
                    pass

        except Exception as e:
            print(str(e))
            return
Ejemplo n.º 40
0
    def get_movie(self, imdb, title, year):
        try:
            t = cleantitle.get(title)

            query = '%s %s' % (title, year)
            query = base64.b64decode(
                self.search_link) % urllib.quote_plus(query)

            result = client.request(query)
            result = json.loads(result)['results']

            result = [(i['url'], i['titleNoFormatting']) for i in result]
            result = [(i[0],
                       re.findall('(?:^Ver |)(.+?)(?: HD |)\((\d{4})', i[1]))
                      for i in result]
            result = [(i[0], i[1][0][0], i[1][0][1]) for i in result
                      if len(i[1]) > 0]

            r = [
                i for i in result if t == cleantitle.get(i[1]) and year == i[2]
            ]

            if len(r) == 0:
                t = 'http://www.imdb.com/title/%s' % imdb
                t = client.request(t, headers={'Accept-Language': 'es-ES'})
                t = client.parseDOM(t, 'title')[0]
                t = re.sub('(?:\(|\s)\d{4}.+', '', t).strip()
                t = cleantitle.get(t)

                r = [
                    i for i in result
                    if t == cleantitle.get(i[1]) and year == i[2]
                ]

            try:
                url = re.findall('//.+?(/.+)', r[0][0])[0]
            except:
                url = r[0][0]
            try:
                url = re.findall('(/.+?/.+?/)', url)[0]
            except:
                pass
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')

            return url
        except:
            pass

        try:
            t = cleantitle.get(title)

            query = self.search3_link % urllib.quote_plus(
                cleantitle.query(title))
            query = urlparse.urljoin(self.base_link, query)

            result = client.request(query)
            result = re.sub(r'[^\x00-\x7F]+', '', result)

            r = result.split('<li class=')
            r = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'i'),
                  re.findall('\((\d{4})\)', i)) for i in r]
            r = [(i[0][0], re.sub('\(|\)', '', i[1][0]), 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] for i in r if t == cleantitle.get(i[1]) and year == i[2]
            ][0]

            try:
                url = re.findall('//.+?(/.+)', r)[0]
            except:
                url = r
            url = client.replaceHTMLCodes(url)
            url = url.encode('utf-8')

            return url
        except:
            pass
Ejemplo n.º 41
0
    def searchShow(self, title, season, year):
        try:
            title = cleantitle.normalize(title)
            t = cleantitle.get(title)

            url = urlparse.urljoin(self.base_link, self.search_link % urllib.quote_plus(cleantitle.query('%s Season %01d' % (title.replace('\'', '-'), int(season)))))
            r = client.request(url, timeout='10')
            r = client.parseDOM(r, 'h2', attrs={'class': 'tit'})
            if r:
                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('(.+?)\s+-\s+Season\s+(\d+)', 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 int(season) == int(i[2])][0]
            else:
                url = urlparse.urljoin(self.base_link, self.search_link % urllib.quote_plus(cleantitle.query('%s %01d' % (title.replace('\'', '-'), int(year)))))
                r = client.request(url, timeout='10')
                r = client.parseDOM(r, 'h2', attrs={'class': 'tit'})
                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)
            return url.encode('utf-8')
        except:
            return
Ejemplo n.º 42
0
    def get_movie(self, imdb, title, year):
        try:
            t = cleantitle.get(title)

            query = "%s %s" % (title, year)
            query = base64.b64decode(self.search_link) % urllib.quote_plus(query)

            result = client.request(query)
            result = json.loads(result)["results"]

            result = [(i["url"], i["titleNoFormatting"]) for i in result]
            result = [(i[0], re.findall("(?:^Ver |)(.+?)(?: HD |)\((\d{4})", i[1])) for i in result]
            result = [(i[0], i[1][0][0], i[1][0][1]) for i in result if len(i[1]) > 0]

            r = [i for i in result if t == cleantitle.get(i[1]) and year == i[2]]

            if len(r) == 0:
                t = "http://www.imdb.com/title/%s" % imdb
                t = client.request(t, headers={"Accept-Language": "es-ES"})
                t = client.parseDOM(t, "title")[0]
                t = re.sub("(?:\(|\s)\d{4}.+", "", t).strip()
                t = cleantitle.get(t)

                r = [i for i in result if t == cleantitle.get(i[1]) and year == i[2]]

            try:
                url = re.findall("//.+?(/.+)", r[0][0])[0]
            except:
                url = r[0][0]
            try:
                url = re.findall("(/.+?/.+?/)", url)[0]
            except:
                pass
            url = client.replaceHTMLCodes(url)
            url = url.encode("utf-8")

            return url
        except:
            pass

        try:
            t = cleantitle.get(title)

            query = self.search3_link % urllib.quote_plus(cleantitle.query(title))
            query = urlparse.urljoin(self.base_link, query)

            result = client.request(query)
            result = re.sub(r"[^\x00-\x7F]+", "", result)

            r = result.split("<li class=")
            r = [
                (client.parseDOM(i, "a", ret="href"), client.parseDOM(i, "i"), re.findall("\((\d{4})\)", i)) for i in r
            ]
            r = [
                (i[0][0], re.sub("\(|\)", "", i[1][0]), 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] for i in r if t == cleantitle.get(i[1]) and year == i[2]][0]

            try:
                url = re.findall("//.+?(/.+)", r)[0]
            except:
                url = r
            url = client.replaceHTMLCodes(url)
            url = url.encode("utf-8")

            return url
        except:
            pass