示例#1
0
	def sources(self, url, hostDict, hostprDict):
		sources = []
		try:
			if url == None:
				raise Exception()

			data = urlparse.parse_qs(url)
			data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data])

			if 'exact' in data and data['exact']:
				titleYear = title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				year = None
				season = None
				episode = None
				pack = False
				packCount = None
			else:
				title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				titleYear = '%s %s' % (title, str(data['year']))
				year = int(data['year']) if 'year' in data and not data['year'] == None else None
				season = int(data['season']) if 'season' in data and not data['season'] == None else None
				episode = int(data['episode']) if 'episode' in data and not data['episode'] == None else None

			query = data['imdb'] if 'imdb' in data and not data['imdb'] == None else title
			url = urlparse.urljoin(self.base_link, self.search_link) % query
			result = json.loads(client.request(url))

			movie = result['data']['movies'][0]
			name = movie['title_long'] + ' '
			torrents = movie['torrents']

			for torrent in torrents:
				quality = torrent['quality']
				if quality.lower() == '3d':
					quality += ' HD1080'
				jsonName = name + quality
				jsonSize = torrent['size_bytes']
				jsonHash = torrent['hash']
				jsonLink = network.Container(jsonHash).torrentMagnet(title = titleYear)
				try: jsonSeeds = int(torrent['seeds'])
				except: jsonSeeds = None

				# Metadata
				meta = metadata.Metadata(name = jsonName, title = title, year = year, season = season, episode = episode, link = jsonLink, size = jsonSize, seeds = jsonSeeds)
				jsonLink = network.Container(jsonHash).torrentMagnet(title = meta.title(extended = True))

				# Ignore
				if meta.ignore(False):
					continue

				# Add
				sources.append({'url' : jsonLink, 'debridonly' : False, 'direct' : False, 'source' : 'torrent', 'language' : self.language[0], 'quality':  meta.videoQuality(), 'metadata' : meta, 'file' : jsonName})

			return sources
		except:
			return sources
示例#2
0
	def _streamIgnore(self, stream):
		try:
			torrent = stream['source'] == OrionStream.TypeTorrent

			# Local stream
			if 'local' in stream and stream['local']: return True

			# Member and premium streams
			if 'memberonly' in stream and stream['memberonly']:
				excluded = False
				for exclude in Orionoid.IgnoreExcludes:
					if ('id' in stream and exclude in stream['id'].lower()) or ('name' in stream and exclude in stream['name'].lower()) or ('provider' in stream and exclude in stream['provider'].lower()) or ('source' in stream and exclude in stream['source'].lower()) or ('hoster' in stream and stream['hoster'] and exclude in stream['hoster'].lower()):
						excluded = True
						break
				if not excluded: return True

			# Not magnet and not http/ftp
			if not network.Networker.linkIs(stream['url']) and not network.Container(stream['url']).torrentIsMagnet(): return True

			# Not FQDN or IP address (eg: http://localhost or http://downloads)
			if not torrent and not '.' in network.Networker.linkDomain(stream['url'], subdomain = True, ip = True): return True

			if not torrent:
				# Streams with cookies and headers
				if '|' in stream['url']: return True

				# Very long links, which are most likely invalid or contain cookie/session data
				if len(stream['url']) > 1024: return True
		except:
			return True
		return False
示例#3
0
	def sources(self, url, hostDict, hostprDict):
		sources = []
		try:
			if url == None: raise Exception()

			ignoreContains = None
			data = self._decode(url)

			if 'exact' in data and data['exact']:
				query = title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				titles = None
				year = None
				season = None
				episode = None
				pack = False
				packCount = None
			else:
				title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				titles = data['alternatives'] if 'alternatives' in data else None
				year = int(data['year']) if 'year' in data and not data['year'] == None else None
				season = int(data['season']) if 'season' in data and not data['season'] == None else None
				episode = int(data['episode']) if 'episode' in data and not data['episode'] == None else None
				pack = data['pack'] if 'pack' in data else False
				packCount = data['packcount'] if 'packcount' in data else None

				if 'tvshowtitle' in data:
					# Search special episodes by name. All special episodes are added to season 0 by Trakt and TVDb. Hence, do not search by filename (eg: S02E00), since the season is not known.
					if (season == 0 or episode == 0) and ('title' in data and not data['title'] == None and not data['title'] == ''):
						title = '%s %s' % (data['tvshowtitle'], data['title']) # Change the title for metadata filtering.
						query = title
						ignoreContains = len(data['title']) / float(len(title)) # Increase the required ignore ration, since otherwise individual episodes and season packs are found as well.
					else:
						if pack: query = '%s %d' % (title, season)
						else: query = '%s S%02dE%02d' % (title, season, episode)
				else:
					query = '%s %d' % (title, year)
				query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query)

			query = urllib.quote_plus(query)
			if not self._query(query): return sources

			pageLimit = tools.Settings.getInteger('scraping.providers.pages')
			pageCounter = 0

			page = 1 # Pages start at 1
			added = False

			timerEnd = tools.Settings.getInteger('scraping.providers.timeout') - 8
			timer = tools.Time(start = True)

			while True:
				# Stop searching 8 seconds before the provider timeout, otherwise might continue searching, not complete in time, and therefore not returning any links.
				if timer.elapsed() > timerEnd:
					break

				pageCounter += 1
				if pageLimit > 0 and pageCounter > pageLimit:
					break

				urlNew = (self.base_link + self.search_link) % (query, page)
				html = BeautifulSoup(client.request(urlNew))
				htmlTable = html.find_all('table', class_ = 'search-table')[0]
				htmlRows = htmlTable.find_all('tr', recursive = False)

				page += 1
				added = False

				for i in range(len(htmlRows)):
					htmlRow = htmlRows[i]
					htmlColumns = htmlRow.find_all('td', recursive = False)

					# Name
					htmlName = htmlColumns[0].getText().strip()

					# Size
					htmlSize = htmlColumns[2].getText().strip()

					# Link
					htmlLink = htmlColumns[0].find_all('a')[0]['href'].strip()
					htmlLink = network.Container(htmlLink).torrentMagnet(title = title)

					# Seeds
					htmlSeeds = int(htmlColumns[3].getText().strip())

					# Metadata
					meta = metadata.Metadata(name = htmlName, title = title, titles = titles, year = year, season = season, episode = episode, pack = pack, packCount = packCount, link = htmlLink, size = htmlSize, seeds = htmlSeeds)

					# Ignore
					meta.ignoreAdjust(contains = ignoreContains)
					if meta.ignore(True): continue

					# Add
					sources.append({'url' : htmlLink, 'debridonly' : False, 'direct' : False, 'source' : 'torrent', 'language' : self.language[0], 'quality':  meta.videoQuality(), 'metadata' : meta, 'file' : htmlName})
					added = True

				if not added: # Last page reached with a working torrent
					break

			return sources
		except:
			return sources
示例#4
0
    def sources(self, url, hostDict, hostprDict):
        sources = []
        try:
            if url == None:
                raise Exception()

            data = urlparse.parse_qs(url)
            data = dict([(i, data[i][0]) if data[i] else (i, '')
                         for i in data])
            pack = None

            if 'exact' in data and data['exact']:
                query = title = data[
                    'tvshowtitle'] if 'tvshowtitle' in data else data['title']
                year = None
                season = None
                episode = None
                pack = False
                packCount = None
            else:
                title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                    'title']
                year = int(
                    data['year']
                ) if 'year' in data and not data['year'] == None else None
                season = int(
                    data['season']
                ) if 'season' in data and not data['season'] == None else None
                episode = int(
                    data['episode']) if 'episode' in data and not data[
                        'episode'] == None else None
                pack = data['pack'] if 'pack' in data else False
                packCount = data['packcount'] if 'packcount' in data else None

                if 'tvshowtitle' in data:
                    if pack: query = ['%s %d' % (title, season)]
                    else:
                        query = [
                            '%s S%02dE%02d' % (title, season, episode),
                            '%s %02dx%02d' % (title, season, episode)
                        ]
                else:
                    query = ['%s %d' % (title, year)]
                query = [
                    re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', q)
                    for q in query
                ]

            for q in query:
                url = urlparse.urljoin(self.base_link,
                                       self.search_link) % urllib.quote_plus(q)

                # Fix HTML closing tags.
                html = client.request(url,
                                      ignoreSsl=True)  # SSL Certificate fails.
                html = re.sub('<span.*>\s*<\/span>\s*<td', '</td><td', html)

                html = BeautifulSoup(html)
                htmlRows = html.find_all('tr', class_=['odd', 'odd2'])
                for i in range(len(htmlRows)):
                    try:
                        htmlColumns = htmlRows[i].find_all('td',
                                                           recursive=False)

                        # Name
                        # Name is abbriviated, use the name in the link instead.
                        htmlName = htmlColumns[1].find_all('a')[0]['href']
                        htmlName = htmlName[htmlName.rfind('/') + 1:]
                        htmlName = htmlName.replace('_', ' ')

                        # Link
                        htmlLink = htmlColumns[3].find_all('input')[0]['value']
                        htmlLink = network.Container(htmlLink).torrentMagnet(
                            title=q, trackers=self.trackers)

                        # Size
                        htmlSize = htmlColumns[2].getText().strip()

                        # Seeds
                        try:
                            htmlSeeds = int(htmlColumns[5].getText().strip())
                        except:
                            htmlSeeds = None

                        # Metadata
                        meta = metadata.Metadata(name=htmlName,
                                                 title=title,
                                                 year=year,
                                                 season=season,
                                                 episode=episode,
                                                 pack=pack,
                                                 packCount=packCount,
                                                 link=htmlLink,
                                                 size=htmlSize,
                                                 seeds=htmlSeeds)
                        meta.mIgnoreLength = 8  # Relax this, otherwise too many links are filtered out (eg: Avatar 2009).

                        # Ignore
                        if meta.ignore(True):
                            continue

                        # Add
                        sources.append({
                            'url': htmlLink,
                            'debridonly': False,
                            'direct': False,
                            'source': 'torrent',
                            'language': self.language[0],
                            'quality': meta.videoQuality(),
                            'metadata': meta,
                            'file': htmlName,
                            'pack': pack
                        })
                    except:
                        pass

            return sources
        except:
            return sources
示例#5
0
    def sources(self, url, hostDict, hostprDict):
        sources = []
        try:
            if url == None:
                raise Exception()

            data = urlparse.parse_qs(url)
            data = dict([(i, data[i][0]) if data[i] else (i, '')
                         for i in data])

            if 'exact' in data and data['exact']:
                query = title = data[
                    'tvshowtitle'] if 'tvshowtitle' in data else data['title']
                year = None
                season = None
                episode = None
                pack = False
                packCount = None
            else:
                title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                    'title']
                year = int(
                    data['year']
                ) if 'year' in data and not data['year'] == None else None
                season = int(
                    data['season']
                ) if 'season' in data and not data['season'] == None else None
                episode = int(
                    data['episode']) if 'episode' in data and not data[
                        'episode'] == None else None
                pack = data['pack'] if 'pack' in data else False
                packCount = data['packcount'] if 'packcount' in data else None

                if 'tvshowtitle' in data:
                    if pack: query = '%s %d' % (title, season)
                    else: query = '%s S%02dE%02d' % (title, season, episode)
                else:
                    query = '%s %d' % (title, year)
                query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query)

            category = self.category_shows if 'tvshowtitle' in data else self.category_movies
            url = urlparse.urljoin(self.base_link, self.search_link)

            pageLimit = tools.Settings.getInteger('scraping.providers.pages')
            pageCounter = 0

            page = 1  # Pages start at 1
            added = False

            timerEnd = tools.Settings.getInteger(
                'scraping.providers.timeout') - 8
            timer = tools.Time(start=True)

            while True:
                # Stop searching 8 seconds before the provider timeout, otherwise might continue searching, not complete in time, and therefore not returning any links.
                if timer.elapsed() > timerEnd:
                    break

                pageCounter += 1
                if pageLimit > 0 and pageCounter > pageLimit:
                    break

                urlNew = url % (category, urllib.quote_plus(query), page)
                html = client.request(urlNew)

                # HTML is corrupt. Try to fix it manually.
                try:
                    indexStart = html.find('class="table2"')
                    indexStart = html.find('<tr bgcolor', indexStart)
                    indexEnd = html.find('search_stat', indexStart)
                    html = html[indexStart:indexEnd]
                    indexEnd = html.rfind('</td>') + 5
                    html = html[:indexEnd]
                    html = html.replace('</a></td>', '</td>')
                    html = '<table>' + html + '</tr></table>'
                except:
                    pass

                html = BeautifulSoup(html)

                page += 1
                added = False

                htmlRows = html.find_all(
                    'tr'
                )  # Do not search further down the tree (just the direct children), because that will also retrieve the header row.
                for i in range(len(htmlRows)):
                    htmlRow = htmlRows[i]
                    htmlColumns = htmlRow.find_all('td')
                    htmlInfo = htmlColumns[0].find_all('div')[0]

                    # Name
                    htmlName = htmlInfo.find_all(
                        'a', recursive=False)[1].getText().strip()

                    # Link
                    htmlHash = htmlInfo.find_all('a',
                                                 recursive=False)[0]['href']
                    indexStart = htmlHash.find('torrent/')
                    if indexStart < 0: continue
                    indexStart += 8
                    indexEnd = htmlHash.find('.torrent', indexStart)
                    if indexEnd < 0: continue
                    htmlHash = htmlHash[indexStart:indexEnd]
                    if not tools.Hash.valid(htmlHash): continue
                    htmlLink = network.Container(htmlHash).torrentMagnet(
                        title=query)

                    # Size
                    htmlSize = htmlColumns[2].getText().strip()

                    # Seeds
                    htmlSeeds = int(htmlColumns[3].getText().replace(
                        ',', '').replace(' ', ''))

                    # Metadata
                    meta = metadata.Metadata(name=htmlName,
                                             title=title,
                                             year=year,
                                             season=season,
                                             episode=episode,
                                             pack=pack,
                                             packCount=packCount,
                                             link=htmlLink,
                                             size=htmlSize,
                                             seeds=htmlSeeds)

                    # Ignore
                    if meta.ignore(True):
                        continue

                    # Add
                    sources.append({
                        'url': htmlLink,
                        'debridonly': False,
                        'direct': False,
                        'source': 'torrent',
                        'language': self.language[0],
                        'quality': meta.videoQuality(),
                        'metadata': meta,
                        'file': htmlName
                    })
                    added = True

                if not added:  # Last page reached with a working torrent
                    break

            return sources
        except:
            return sources
示例#6
0
	def sources(self, url, hostDict, hostprDict):
		sources = []
		try:
			if url == None:
				raise Exception()

			data = urlparse.parse_qs(url)
			data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data])

			if 'exact' in data and data['exact']:
				query = title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				year = None
				season = None
				episode = None
				pack = False
				packCount = None
			else:
				title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				year = int(data['year']) if 'year' in data and not data['year'] == None else None
				season = int(data['season']) if 'season' in data and not data['season'] == None else None
				episode = int(data['episode']) if 'episode' in data and not data['episode'] == None else None
				pack = data['pack'] if 'pack' in data else False
				packCount = data['packcount'] if 'packcount' in data else None

				if 'tvshowtitle' in data:
					if pack: query = '%s %d' % (title, season)
					else: query = '%s S%02dE%02d' % (title, season, episode)
				else:
					query = '%s %d' % (title, year)
				query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query)

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

			pageLimit = tools.Settings.getInteger('scraping.providers.pages')
			pageCounter = 0

			page = 0
			added = False

			timerEnd = tools.Settings.getInteger('scraping.providers.timeout') - 8
			timer = tools.Time(start = True)

			while True:
				# Stop searching 8 seconds before the provider timeout, otherwise might continue searching, not complete in time, and therefore not returning any links.
				if timer.elapsed() > timerEnd:
					break

				pageCounter += 1
				if pageLimit > 0 and pageCounter > pageLimit:
					break

				urlNew = url % (urllib.quote_plus(query), page)
				html = BeautifulSoup(client.request(urlNew))

				page += 1
				added = False

				htmlTable = html.find_all('div', class_ = 'results')[0]
				htmlRows = htmlTable.find_all('dl', recursive = False)
				for i in range(0, len(htmlRows)):
					htmlRow = htmlRows[i]

					# Name
					htmlName = htmlRow.find_all('dt')[0].find_all('a', recursive = False)[0].getText().strip()

					# Size
					htmlSize = htmlRow.find_all('dd')[0].find_all('span')[2].getText().strip()

					# Link
					htmlLink = htmlRow.find_all('dt')[0].find_all('a', recursive = False)[0]['href'].replace('/', '').strip()
					htmlLink = network.Container(htmlLink).torrentMagnet(title = title)

					# Seeds
					htmlSeeds = int(htmlRow.find_all('dd')[0].find_all('span')[3].getText().strip())

					# Metadata
					meta = metadata.Metadata(name = htmlName, title = title, year = year, season = season, episode = episode, pack = pack, packCount = packCount, link = htmlLink, size = htmlSize, seeds = htmlSeeds)

					# Ignore
					if meta.ignore(True):
						continue

					# Add
					sources.append({'url' : htmlLink, 'debridonly' : False, 'direct' : False, 'source' : 'torrent', 'language' : self.language[0], 'quality': meta.videoQuality(), 'metadata' : meta, 'file' : htmlName})
					added = True

				if not added: # Last page reached with a working torrent
					break

			return sources
		except:
			return sources
示例#7
0
    def sources(self, url, hostDict, hostprDict):
        sources = []
        try:
            if url == None:
                raise Exception()

            data = urlparse.parse_qs(url)
            data = dict([(i, data[i][0]) if data[i] else (i, '')
                         for i in data])

            type = self.type_tvshows if (
                'tvshowtitle' in data and not data['tvshowtitle'] == None
                and not data['tvshowtitle'] == '') else self.type_movies
            title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                'title']
            titleYear = '%s S%02dE%02d' % (
                data['tvshowtitle'], int(data['season']), int(data['episode'])
            ) if 'tvshowtitle' in data else '%s (%s)' % (data['title'],
                                                         data['year'])

            title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                'title']
            year = int(
                data['year']
            ) if 'year' in data and not data['year'] == None else None
            season = int(
                data['season']
            ) if 'season' in data and not data['season'] == None else None
            episode = int(
                data['episode']
            ) if 'episode' in data and not data['episode'] == None else None
            pack = data['pack'] if 'pack' in data else False

            if 'tvshowtitle' in data:
                if pack: query = '%s %d' % (title, season)
                else: query = '%s S%02dE%02d' % (title, season, episode)
            else:
                query = '%s %d' % (title, year)
            query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query)
            url = urlparse.urljoin(self.base_link, self.search_link)

            page = 1
            added = False

            timerEnd = tools.Settings.getInteger(
                'scraping.providers.timeout') - 8
            timer = tools.Time(start=True)

            while True:
                # Stop searching 8 seconds before the provider timeout, otherwise might continue searching, not complete in time, and therefore not returning any links.
                if timer.elapsed() > timerEnd:
                    break

                urlNew = url % (urllib.quote_plus(query), type, page)
                html = BeautifulSoup(client.request(urlNew))

                page += 1
                added = False

                htmlTable = html.find_all('div', id='div2child')[0]
                htmlRows = htmlTable.find_all(
                    'div', class_='resultdiv', recursive=False
                )  # Do not search further down the tree (just the direct children), because that will also retrieve the header row.

                for i in range(len(htmlRows)):
                    htmlRow = htmlRows[i]
                    htmlInfo = htmlRow.find_all('div',
                                                class_='resultdivbotton')[0]

                    # Name
                    htmlName = htmlRow.find_all(
                        'div', class_='resultdivtop')[0].find_all(
                            'div',
                            class_='resultdivtopname')[0].getText().strip()

                    # Size
                    htmlSize = htmlInfo.find_all(
                        'div', class_='resultlength')[0].find_all(
                            'div',
                            class_='resultdivbottonlength')[0].getText()

                    # Link
                    htmlHash = htmlInfo.find_all(
                        'div', class_='hideinfohash')[0].getText()
                    htmlLink = network.Container(htmlHash).torrentMagnet(
                        title=titleYear)

                    # Seeds
                    htmlSeeds = int(
                        htmlInfo.find_all(
                            'div', class_='resultseed')[0].find_all(
                                'div',
                                class_='resultdivbottonseed')[0].getText())

                    # Metadata
                    meta = metadata.Metadata(name=htmlName,
                                             title=title,
                                             year=year,
                                             season=season,
                                             episode=episode,
                                             pack=pack,
                                             link=htmlLink,
                                             size=htmlSize,
                                             seeds=htmlSeeds)

                    # Ignore
                    if meta.ignore(True):
                        continue

                    # Add
                    sources.append({
                        'url': htmlLink,
                        'debridonly': False,
                        'direct': False,
                        'source': 'torrent',
                        'language': self.language[0],
                        'quality': meta.videoQuality(),
                        'info': meta.information(),
                        'file': htmlName
                    })
                    added = True

                if not added:  # Last page reached with a working torrent
                    break

            return sources
        except:
            return sources
示例#8
0
	def sources(self, url, hostDict, hostprDict):
		sources = []
		try:
			if url == None:
				raise Exception()

			ignoreContains = None
			data = self._decode(url)

			if 'exact' in data and data['exact']:
				query = title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				titles = None
				year = None
				season = None
				episode = None
				pack = False
				packCount = None
			else:
				title = data['tvshowtitle'] if 'tvshowtitle' in data else data['title']
				titles = data['alternatives'] if 'alternatives' in data else None
				year = int(data['year']) if 'year' in data and not data['year'] == None else None
				season = int(data['season']) if 'season' in data and not data['season'] == None else None
				episode = int(data['episode']) if 'episode' in data and not data['episode'] == None else None
				pack = data['pack'] if 'pack' in data else False
				packCount = data['packcount'] if 'packcount' in data else None

				if 'tvshowtitle' in data:
					# Search special episodes by name. All special episodes are added to season 0 by Trakt and TVDb. Hence, do not search by filename (eg: S02E00), since the season is not known.
					if (season == 0 or episode == 0) and ('title' in data and not data['title'] == None and not data['title'] == ''):
						title = '%s %s' % (data['tvshowtitle'], data['title']) # Change the title for metadata filtering.
						query = [title]
						ignoreContains = len(data['title']) / float(len(title)) # Increase the required ignore ration, since otherwise individual episodes and season packs are found as well.
					else:
						if pack: query = ['%s %d' % (title, season)]
						else: query = ['%s S%02dE%02d' % (title, season, episode), '%s %02dx%02d' % (title, season, episode)]
				else:
					query = ['%s %d' % (title, year)]
				query = [re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', q) for q in query]

			if not self._query(query): return sources

			for q in query:
				url = urlparse.urljoin(self.base_link, self.search_link) % urllib.quote_plus(q)

				# Fix HTML closing tags.
				html = client.request(url, ignoreSsl = True) # SSL Certificate fails.
				html = re.sub('<span.*>\s*<\/span>\s*<td', '</td><td', html)

				html = BeautifulSoup(html)
				htmlRows = html.find_all('tr', class_ = ['odd', 'odd2'])
				for i in range(len(htmlRows)):
					try:
						htmlColumns = htmlRows[i].find_all('td', recursive = False)

						# Name
						# Name is abbriviated, use the name in the link instead.
						htmlName = htmlColumns[1].find_all('a')[0]['href']
						htmlName = htmlName[htmlName.rfind('/') + 1:]
						htmlName = htmlName.replace('_', ' ')

						# Link
						htmlLink = htmlColumns[3].find_all('input')[0]['value']
						htmlLink = network.Container(htmlLink).torrentMagnet(title = q, trackers = self.trackers)

						# Size
						htmlSize = htmlColumns[2].getText().strip()

						# Seeds
						try: htmlSeeds = int(htmlColumns[5].getText().strip())
						except: htmlSeeds = None

						# Metadata
						meta = metadata.Metadata(name = htmlName, title = title, titles = titles, year = year, season = season, episode = episode, pack = pack, packCount = packCount, link = htmlLink, size = htmlSize, seeds = htmlSeeds)
						meta.mIgnoreLength = 8 # Relax this, otherwise too many links are filtered out (eg: Avatar 2009).

						# Ignore
						meta.ignoreAdjust(contains = ignoreContains)
						if meta.ignore(True): continue

						# Add
						sources.append({'url' : htmlLink, 'debridonly' : False, 'direct' : False, 'source' : 'torrent', 'language' : self.language[0], 'quality': meta.videoQuality(), 'metadata' : meta, 'file' : htmlName, 'pack' : pack})
					except:
						pass

			return sources
		except:
			return sources
示例#9
0
    def sources(self, url, hostDict, hostprDict):
        sources = []
        try:
            if url == None:
                raise Exception()

            data = urlparse.parse_qs(url)
            data = dict([(i, data[i][0]) if data[i] else (i, '')
                         for i in data])

            title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                'title']
            year = int(
                data['year']
            ) if 'year' in data and not data['year'] == None else None
            season = int(
                data['season']
            ) if 'season' in data and not data['season'] == None else None
            episode = int(
                data['episode']
            ) if 'episode' in data and not data['episode'] == None else None
            pack = data['pack'] if 'pack' in data else False

            if 'tvshowtitle' in data:
                if pack: query = '%s %d' % (title, season)
                else: query = '%s S%02dE%02d' % (title, season, episode)
            else:
                query = '%s %d' % (title, year)
            query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', ' ', query)
            querySplit = query.split()

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

            page = 0  # Pages start at 0
            added = False

            timerEnd = tools.Settings.getInteger(
                'scraping.providers.timeout') - 8
            timer = tools.Time(start=True)

            while True:
                # Stop searching 8 seconds before the provider timeout, otherwise might continue searching, not complete in time, and therefore not returning any links.
                if timer.elapsed() > timerEnd:
                    break

                urlNew = url % (page, urllib.quote_plus(query))
                html = BeautifulSoup(client.request(urlNew))

                page += 1
                added = False

                htmlTable = html.find_all('div', id='ires')[0].find_all(
                    'ol', recursive=False)[0]
                htmlRows = htmlTable.find_all(
                    'li', recursive=False
                )  # Do not search further down the tree (just the direct children), because that will also retrieve the header row.

                for i in range(len(htmlRows)):
                    row1 = htmlRows[i].find_all('h3', class_='r')[0]
                    row2 = htmlRows[i].find_all('div', class_='sti')[0]

                    # Name
                    htmlName = row1.find_all(
                        'a', class_='tl',
                        recursive=False)[0].getText().strip()

                    # Link
                    htmlHash = row1.find_all('a', class_='tl',
                                             recursive=False)[0]['href']
                    if htmlHash.startswith('/'):
                        htmlHash = htmlHash[1:]
                    index = htmlHash.find('/')
                    if index > 0:
                        htmlHash = htmlHash[:index]
                    if not tools.Hash.valid(htmlHash):
                        continue
                    htmlLink = network.Container(htmlHash).torrentMagnet(
                        title=query)

                    # Size
                    htmlSize = row2.find_all(
                        'span', class_='torrent-size')[0].getText().strip()

                    # Seeds
                    htmlSeeds = int(
                        row2.find_all('span', class_='seeders')[0].find_all(
                            'span', class_='gac_b')[0].getText().strip())

                    # Metadata
                    meta = metadata.Metadata(name=htmlName,
                                             title=title,
                                             year=year,
                                             season=season,
                                             episode=episode,
                                             pack=pack,
                                             link=htmlLink,
                                             size=htmlSize,
                                             seeds=htmlSeeds)

                    # Ignore
                    if meta.ignore(True):
                        continue

                    # Ignore Name
                    # TorrentProject has a lot of season packs, foreign titles, and other torrents that should be excluded. If the name does not contain the exact search string, ignore the result.
                    if not all(q in htmlName for q in querySplit):
                        continue

                    # Add
                    sources.append({
                        'url': htmlLink,
                        'debridonly': False,
                        'direct': False,
                        'source': 'torrent',
                        'language': self.language[0],
                        'quality': meta.videoQuality(),
                        'info': meta.information(),
                        'file': htmlName
                    })
                    added = True

                if not added:  # Last page reached with a working torrent
                    break

            return sources
        except:
            return sources