Пример #1
0
 def __init__(self):
     self.domain = "katcr.co"
     self.base_link = 'https://katcr.co'
     self.search_link = '/advanced-usearch/'
     self.threads = []
     self.threadResults = []
     self.session = serenRequests()
Пример #2
0
    def movie(self, title, year):

        torrent_list = []
        self.get_token()
        title = source_utils.cleanTitle(title)
        url = self.base_link + self.search_string % (tools.quote(
            '%s %s' % (title, year)), 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.filterMovieTitle(
                            torrent['release_title'], title, year):
                        continue
                    torrent['magnet'] = i['download']
                    torrent['seeds'] = i['seeders']
                    torrent['size'] = int((i['size'] / 1024) / 1024)
                    torrent_list.append(torrent)
                except:
                    import traceback
                    traceback.print_exc()
                    continue

        return torrent_list
Пример #3
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
Пример #4
0
    def show_pack(self, simpleInfo, allInfo):

        season = 1
        no_seasons = simpleInfo['no_seasons']

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

        url = self.base_link + self.search_link % query
        print(url)
        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.filterShowPack(simpleInfo, release_title):
                self.showPackThreads.append(
                    threading.Thread(target=self.info_thread,
                                     args=(release_title, url, 'show')))

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

        return
Пример #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
Пример #6
0
    def showPack(self, simpleInfo, allInfo):

        try:
            showTitle = source_utils.cleanTitle(simpleInfo['show_title'])

            url = self.base_link + self.search_link + tools.quote(
                '%s season 1-%s' % (showTitle, simpleInfo['no_seasons']))
            response = serenRequests().get(url, timeout=10)
            try:
                if response.status_code != 200:
                    return
            except:
                return
            webpage = BeautifulSoup(response.text, 'html.parser')
            results = webpage.find_all('tr')

            url = self.base_link + self.search_link + tools.quote(
                '%s complete' % showTitle)
            response = serenRequests().get(url)
            webpage = BeautifulSoup(response.text, 'html.parser')
            results += webpage.find_all('tr')

            torrent_list = []

            for i in results:
                try:
                    torrent = {}
                    torrent['package'] = 'pack'
                    torrent['release_title'] = i.find('a', {'class', 'detLink'}).text
                    if not source_utils.filterShowPack(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:
                    continue

            self.threadResults += torrent_list

        except:
            pass
Пример #7
0
    def episode(self, simpleInfo, allInfo):
        logging.warning(simpleInfo)
        torrent_list = []
        show_title = source_utils.cleanTitle(simpleInfo['show_title'])
        year = simpleInfo['year']
        country = simpleInfo['country']
        show_string_list = [
            show_title,
            '%s %s' % (show_title, year),
            '%s %s' % (show_title, country)
        ]
        response = serenRequests().get(self.base_link + self.search_link)
        show_list = BeautifulSoup(response.text,
                                  'html.parser').find_all('option')
        show_id = None
        for show in show_list:
            if source_utils.cleanTitle(show.text.lower()) in [
                    i.lower() for i in show_string_list
            ]:
                show_id = show['value']

        if show_id is None: return

        response = serenRequests().get(self.base_link +
                                       self.feed_url % show_id)
        torrents = BeautifulSoup(response.text, 'html.parser').find_all('item')
        for item in torrents:
            try:
                if '%sx%s' % (simpleInfo['season_number'],
                              simpleInfo['episode_number'].zfill(2)
                              ) in item.find('title').text:
                    torrent = {}
                    torrent['package'] = 'single'
                    torrent['release_title'] = re.findall(
                        r'<tv:raw_title>(.*?)</tv:raw_title>', str(item))[0]
                    torrent['magnet'] = re.findall(r'<link/>(.*?)<guid',
                                                   str(item))[0]
                    torrent['seeds'] = 0
                    torrent_list.append(torrent)
            except:
                pass

        return torrent_list
Пример #8
0
 def info_thread(self, release_title, url, package):
     url = self.base_link + url
     response = serenRequests().get(url)
     torrent = {}
     torrent['release_title'] = release_title
     torrent['magnet'] = re.findall(r'href="(magnet:?.*?)"',
                                    response.text)[0]
     size = re.findall(r'<strong>Total size</strong> <span>(.*?)</span>',
                       response.text)[0]
     torrent['size'] = source_utils.de_string_size(size)
     torrent['seeds'] = re.findall(
         r'<strong>Seeders</strong> <span class="seeds">(.*?)</span>',
         response.text)[0]
     torrent['package'] = package
     self.torrent_list.append(torrent)
Пример #9
0
 def movie(self, title, year):
     url = self.base_link + self.search_link + tools.quote('%s %s' % (title, year))
     response = serenRequests().get(url, timeout=10)
     results = BeautifulSoup(response.text, 'html.parser').find_all('tr')
     torrent_list = []
     for i in results:
         try:
             torrent = {}
             torrent['package'] = 'single'
             torrent['release_title'] = i.find('a', {'class', 'detLink'}).text
             if not source_utils.filterMovieTitle(torrent['release_title'], title, year):
                 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:
             continue
     return torrent_list
Пример #10
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
Пример #11
0
    def movie(self, title, year):

        url = self.search_link % quote_plus('%s %s' % (title, year))
        url = self.base_link + url
        try:
            search_results = self.searchResults(serenRequests().get(url))
        except:
            return

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

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

        return self.torrent_list
Пример #12
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
Пример #13
0
    def get_token(self):

        url = self.base_link + '&get_token=get_token'
        response = serenRequests().get(url)
        self.token = json.loads(response.text)['token']
Пример #14
0
 def magnet_request(self, url):
     response = serenRequests().get(url)
     magnet = BeautifulSoup(response.text, 'html.parser').find('div', {'class':'download'})
     magnet = magnet.find('a')['href']
     return magnet