Ejemplo n.º 1
0
    def getLocalTorrentResults(self):
        local_storage = database.getTorrents(self.trakt_id)
        relevant_torrents = []

        if 'showInfo' in self.args:
            simple_info = self.buildSimpleShowInfo(self.args)
            for torrent in local_storage:
                if source_utils.filterShowPack(simple_info,
                                               torrent['release_title']):
                    relevant_torrents.append(torrent)
                if source_utils.filterSingleEpisode(simple_info,
                                                    torrent['release_title']):
                    relevant_torrents.append(torrent)
                if source_utils.filterSeasonPack(simple_info,
                                                 torrent['release_title']):
                    relevant_torrents.append(torrent)
        else:
            relevant_torrents = local_storage

        if len(relevant_torrents) > 0:
            for torrent in relevant_torrents:
                torrent['source'] = 'Local Cache'
            self.allTorrents += relevant_torrents
            self.torrentCacheSources += TorrentCacheCheck().torrentCacheCheck(
                relevant_torrents, self.args)
Ejemplo n.º 2
0
    def singleEpisode(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])
            season = simpleInfo['season_number'].zfill(2)
            episode = simpleInfo['episode_number'].zfill(2)

            url = self.base_link + self.search_link % tools.quote('%s s%se%s' % (showTitle, season, episode))
            results = self.getList(url)

            torrent_list = []

            for torrent in results:
                try:
                    if not source_utils.filterSingleEpisode(simpleInfo, torrent['release_title']):
                        continue
                    else:
                        torrent['package'] = 'single'
                        torrent_list.append(torrent)
                except:
                    continue

            self.threadResults += torrent_list
        except:
            import traceback
            traceback.print_exc()
            pass
Ejemplo n.º 3
0
    def singleEpisode(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])
            season = simpleInfo['season_number'].zfill(2)
            episode = simpleInfo['episode_number'].zfill(2)

            url = self.base_link + '%s/%s' % (showTitle[:1], '%s s%se%s' %
                                              (showTitle, season, episode))
            url = url.replace(' ', '-')
            results = self.getList(url)
            results = self.get_info(results, 'single')
            torrent_list = []

            for torrent in results:
                try:
                    if not source_utils.filterSingleEpisode(
                            simpleInfo, torrent['release_title']):
                        continue
                    torrent_list.append(torrent)
                except:
                    continue

            self.threadResults += torrent_list
        except:
            pass
Ejemplo n.º 4
0
    def singleEpisode(self, simpleInfo, allInfo):

        season = simpleInfo['season_number'].zfill(2)
        episode = simpleInfo['episode_number'].zfill(2)

        query = quote_plus(simpleInfo['show_title'] + ' s%se%s' %
                           (season, episode))

        url = self.base_link + self.search_link % query

        try:
            search_results = self.searchResults(serenRequests().get(url))
        except:
            import traceback
            traceback.print_exc()
            return

        for i in search_results:
            release = i.findAll('a')[1]
            url = release['href']
            release_title = release.text
            if source_utils.filterSingleEpisode(simpleInfo, release_title):
                self.singleThreads.append(
                    threading.Thread(target=self.info_thread,
                                     args=(release_title, url, 'single')))

        for i in self.singleThreads:
            i.start()
        for i in self.singleThreads:
            i.join()

        return
Ejemplo n.º 5
0
    def episode(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])
            season = simpleInfo['season_number'].zfill(2)
            episode = simpleInfo['episode_number'].zfill(2)

            url = self.base_link + self.search_link % tools.quote_plus('%s s%se%s' % (showTitle, season, episode))
            response = serenRequests().get(url)
            results = BeautifulSoup(response.text, 'html.parser').find_all('tr', {'class': 'forum_header_border'})

            torrent_list = []

            for i in results:
                try:
                    torrent = {}
                    torrent['package'] = 'single'
                    torrent['release_title'] = i.find('a', {'class': 'epinfo'}).text
                    if not source_utils.filterSingleEpisode(simpleInfo, torrent['release_title']):
                        continue

                    torrent['magnet'] = i.find('a', {'class': 'magnet'})['href']
                    size = i.find_all('td')[3].text
                    size = source_utils.de_string_size(size)
                    torrent['size'] = size
                    torrent['seeds'] = 0
                    torrent_list.append(torrent)
                except:
                    continue

            return torrent_list
        except:
            import traceback
            traceback.print_exc()
            pass
Ejemplo n.º 6
0
    def singleEpisode(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])
            season = simpleInfo['season_number'].zfill(2)
            episode = simpleInfo['episode_number'].zfill(2)

            url = self.base_link + self.search_link + tools.quote('%s s%se%s' % (showTitle, season, episode))
            response = serenRequests().get(url, timeout=10)
            webpage = BeautifulSoup(response.text, 'html.parser')
            results = webpage.find_all('tr')
            torrent_list = []

            page_limit = 2
            torrent_list = []

            for x in range(1, page_limit):
                for i in results:
                    try:
                        torrent = {}
                        torrent['package'] = 'single'
                        torrent['release_title'] = i.find('a', {'class', 'detLink'}).text

                        if not source_utils.filterSingleEpisode(simpleInfo, torrent['release_title']):
                            continue

                        torrent['magnet'] = i.find_all('a')[3]['href']
                        if 'magnet:?' not in torrent['magnet']:
                            torrent['magnet'] = self.magnet_request(torrent['magnet'])
                        torrent['seeds'] = int(i.find_all('td')[2].text)
                        torrent_list.append(torrent)
                    except:
                        import traceback
                        traceback.print_exc()
                        continue

                self.threadResults += torrent_list
        except:
            pass
Ejemplo n.º 7
0
    def episode(self, simpleInfo, allInfo):
        logging.warning('1')
        torrent_list = []
        self.get_token()
        show_title = simpleInfo['show_title'].replace('.', '')
        show_title = source_utils.cleanTitle(show_title)
        season = simpleInfo['season_number'].zfill(2)
        episode = simpleInfo['episode_number'].zfill(2)
        season_pack_query = '%s s%s' % (show_title, season)
        single_episode_query = '%s s%se%s' % (show_title, season, episode)

        url = self.base_link + self.search_string % (
            tools.quote(season_pack_query), self.token)
        tools.log(url)
        response = json.loads(serenRequests().get(url).text)
        for i in response:
            tools.log(i)
        if 'error_code' in response:
            tools.log(str(response))
            pass
        else:
            for i in response['torrent_results']:
                try:
                    torrent = {}
                    torrent['package'] = 'season'
                    torrent['release_title'] = i['title']
                    if not source_utils.filterSeasonPack(
                            simpleInfo, torrent['release_title']):
                        continue
                    torrent['magnet'] = i['download']
                    torrent['seeds'] = i['seeders']
                    torrent['size'] = int((i['size'] / 1024) / 1024)
                    torrent_list.append(torrent)
                except Exception as e:
                    logging.warning(e)
                    #import traceback
                    #traceback.print_exc()
                    continue

        time.sleep(2)

        url = self.base_link + self.search_string % (
            tools.quote(single_episode_query), self.token)
        response = json.loads(serenRequests().get(url).text)

        if 'error_code' in response:
            pass
        else:
            for i in response['torrent_results']:
                try:
                    torrent = {}
                    torrent['package'] = 'single'
                    torrent['release_title'] = i['title']
                    if not source_utils.filterSingleEpisode(
                            simpleInfo, torrent['release_title']):
                        continue
                    torrent['magnet'] = i['download']
                    torrent['seeds'] = i['seeders']
                    torrent['size'] = int((i['size'] / 1024) / 1024)
                    torrent_list.append(torrent)
                except Exception as e:
                    logging.warning(e)
                    #import traceback
                    #traceback.print_exc()
                    continue
        for i in torrent_list:
            tools.log(i)
        return torrent_list