Exemplo n.º 1
0
 def get(self, request):
     query = request.query_params.get('q')
     media_type = request.query_params.get('media_type', MEDIA_TYPE_MOVIE)
     search = SearchTorrents(media_type, query)
     if not search.ok:
         return Response({'error': search.error_content}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     return Response(search.results)
Exemplo n.º 2
0
    def _get_search_results(self):
        # query the show name AND the season/episode name separately
        # i.e search for "Atlanta" and "Atlanta s01e05" individually for best results
        watch_episode = self.watch_media  # type: WatchTVEpisode
        show_result = self.tmdb_client.TV(watch_episode.watch_tv_show.tmdb_show_id)
        show = show_result.info()

        return SearchTorrentsCombined([
            # search the show name
            SearchTorrents(MEDIA_TYPE_TV, show['name']),
            # search the show name and the season/episode combination
            SearchTorrents(MEDIA_TYPE_TV, '{} s{:02d}e{:02d}'.format(
                show['name'],
                self.tmdb_media['season_number'],
                self.tmdb_media['episode_number'],
            )),
        ])
Exemplo n.º 3
0
    def _get_search_results(self):
        # query the show name AND the season/episode name separately
        # i.e search for "Atlanta" and "Atlanta s01e05" individually for best results
        watch_episode = self.watch_media  # type: WatchTVEpisode
        show_result = self.tmdb_client.TV(watch_episode.watch_tv_show.tmdb_show_id)
        params = {
            'language': self.nefarious_settings.language,
        }
        show = show_result.info(**params)

        media_title = self._sanitize_title(show['name'])

        return SearchTorrentsCombined([
            # search the show name
            SearchTorrents(SEARCH_MEDIA_TYPE_TV, media_title),
            # search the show name and the season/episode combination
            SearchTorrents(SEARCH_MEDIA_TYPE_TV, '{} s{:02d}e{:02d}'.format(
                media_title,
                self.tmdb_media['season_number'],
                self.tmdb_media['episode_number'],
            )),
        ])
Exemplo n.º 4
0
 def _get_search_results(self):
     media = self.tmdb_media
     return SearchTorrents(MEDIA_TYPE_TV, media[self._get_tmdb_title_key()])
Exemplo n.º 5
0
def cross_seed_task(torrent_hash: str):
    # TODO - this isn't used and is a work in progress

    nefarious_settings = NefariousSettings.get()
    transmission_client = get_transmission_client(nefarious_settings)

    try:
        torrent = transmission_client.get_torrent(torrent_hash)
    except KeyError:
        logging.warning('{} no longer in transmission'.format(torrent_hash))
        return

    logging.info('Attempting cross seed for {}'.format(torrent.name))

    valid_results = []

    search = SearchTorrents(MEDIA_TYPE_MOVIE,
                            torrent.name,
                            search_seed_only=True)
    if search.ok:
        for result in search.results:
            transmission_client.add_torrent()
            normalized_title = regex.sub(ParserBase.word_delimiter_regex, ' ',
                                         torrent.name)
            if result['Title'].lower() in [
                    torrent.name.lower(),
                    normalized_title.lower()
            ]:
                # TODO - the sizes won't match due to the inaccuracy of the scraping values
                # add paused torrent and verify the sizes match
                valid_results.append(result)

    # trace the "torrent url" (sometimes magnet) in each valid result
    valid_results = results_with_valid_urls(valid_results, nefarious_settings)

    logging.info(valid_results)

    seed_only_indexers = get_seed_only_indexers(nefarious_settings)

    if valid_results:
        for seed_only_indexer in seed_only_indexers:

            logging.info(
                'Looking for cross seed results for indexer {}'.format(
                    seed_only_indexer))

            # filter results to this seed-only indexer
            indexer_results = [
                r for r in valid_results if r['TrackerId'] == seed_only_indexer
            ]
            if not indexer_results:
                logging.info(
                    'Indexer {} does not have any results for {}'.format(
                        seed_only_indexer, torrent.name))
                continue

            # get the "best" result
            best_result = get_best_torrent_result(indexer_results)

            logging.info('Cross seeding {} for indexer {}'.format(
                best_result['Title'], best_result['Tracker']))

            # add a new key to our result object with the traced torrent url
            best_result[
                'torrent_url'] = best_result['MagnetUri'] or trace_torrent_url(
                    swap_jackett_host(best_result['Link'], nefarious_settings))

            # add to transmission
            transmission_session = transmission_client.session_stats()
            torrent = transmission_client.add_torrent(
                best_result['torrent_url'],
                paused=True,  # TODO
                # TODO
                #download_dir=self._get_download_dir(transmission_session)
            )
    else:
        logging.info('No valid cross seeding options for {}'.format(
            torrent.name))
Exemplo n.º 6
0
 def _get_search_results(self):
     media = self.tmdb_media
     return SearchTorrents(
         SEARCH_MEDIA_TYPE_TV,
         self._sanitize_title(media[self._get_tmdb_title_key()]))