Exemplo n.º 1
0
def MovieSearch(moviename):
    rarbgclient = rarbgapi.RarbgAPI()

    Qs = [
        'CATEGORY_MOVIE_H265_4K_HDR', 'CATEGORY_MOVIE_H265_4K',
        'CATEGORY_MOVIE_H264_4K', 'CATEGORY_MOVIE_H264_1080P'
    ]
    Qualities = []
    for q in Qs:
        cat = eval('rarbgapi.RarbgAPI.' + q)
        Qualities.append(cat)

    movienamealt = moviename.replace(' ', '.')
    alts = [movienamealt, moviename]
    counter = 0
    for q in Qualities:
        # print(q)
        for x in alts:
            searchresult = rarbgclient.search(limit=10,
                                              search_string=x,
                                              category=q)
            if len(searchresult) != 0:
                # for torrent in searchresult:
                #     print(torrent.download)
                firsthit = searchresult[0]
                torrent = firsthit.download
                return torrent
            else:
                counter += 1
                if counter == len(Qualities) * len(alts):
                    response = 'No results found'
                    return response
Exemplo n.º 2
0
    async def search(self, ctx, *truc):
        search = ' '.join(truc)
        rarbg = rarbgapi.RarbgAPI()
        found = rarbg.search(search_string=search, sort='last')
        result = f"Searching for {search} .. {len(found)} results found\n"
        for i in found:
            result += f"{i.filename} ({i.category})\n"

        await ctx.send(f'```\n{result}\n```')
Exemplo n.º 3
0
	async def dl(self, ctx, torrent):
		rarbg = rarbgapi.RarbgAPI()
		i = rarbg.search(search_string=torrent, sort='last')[0]
		await ctx.send(f'{i.filename} ({i.category}) has been scheduled for download')
		if transmission_auth is not None:
			c = Client(path='/torrent', username=transmission_auth[0], password=transmission_auth[1])
		else:
			c = Client(path='/torrent')
		c.add_torrent(i.download)
Exemplo n.º 4
0
def search_torrents(label):
    """
    Function that searches for torrents from the RARBG API
    """

    print("Searching torrents... please wait")

    client = rarbgapi.RarbgAPI()
    torrents = client.search(search_string=label, limit=100)

    return torrents
Exemplo n.º 5
0
 def __init__(self, retries: int = 3):
     self._client = rarbgapi.RarbgAPI(retries=retries)
     self._searchRetries = retries
Exemplo n.º 6
0
    omdb_response = requests.get(OMDB_URL, params=OMDB_PARAMS)
    omdb_result = omdb_response.json()

    yts_response = requests.get(YTS_URL, params=YTS_PARAMS)
    yts_result = yts_response.json()
    yts_data = ''
    if yts_result['data']['movie_count'] > 0:
        try:
            yts_data = '=HYPERLINK("{}","YTS")'.format(
                yts_result['data']['movies'][0]['url'])
        except KeyError:
            print(movie_id)
            print(yts_result['data'])

    rarbg = rarbgapi.RarbgAPI()
    rarbg_result = []
    try:
        rarbg_result = rarbg.search(search_imdb=movie_id)
    except:
        pass
    # except ValueError:
    #     print("Rarbgapi error on id: " + movie_id)

    rarbg_data = ''
    if len(rarbg_result) > 0 or rarbg_result:
        rarbg_data = '=HYPERLINK("{}","RARBG")'.format(
            RARBG_URL.format(movie_id))

    DATA_USERS_RATINGS = []
    for user_rating in USERS_RATINGS:
Exemplo n.º 7
0
import requests
from flask import Flask, redirect, render_template, request, session, url_for
from flask_cors import CORS

import rarbgapi

sys.path.insert(0, '..')
import keys

app = Flask(__name__)

CORS(app, origins=r"*")

OMBD_URL = "http://www.omdbapi.com/"
TORRENT_API = rarbgapi.RarbgAPI()

SUPPORTED_CATEGORIES = {
    "software": TORRENT_API.CATEGORY_SOFTWARE,
    "ebooks": TORRENT_API.CATEGORY_EBOOK,
    "movies": TORRENT_API.CATEGORY_MOVIES_ALL,
    "TV-series": TORRENT_API.CATEGORY_TV_ALL,
    "music": TORRENT_API.CATEGORY_MUSIC_ALL,
    "games": TORRENT_API.CATEGORY_GAMES_ALL,
    "all": None
}


@app.errorhandler(404)
def page_not_found(e):
Exemplo n.º 8
0
#!/usr/bin/python3
# Function: best_magnet_links
# Input: Parameters for best_movies_imdb, max result to return and a rarbg filter (see default_rarbg_filter)
# Output: A generator that returns tuples of the form: ('tt0252487', 'magnet:xxxx')

from find_top_imdb import best_movies_imdb, default_imdb_filter
import rarbgapi
import json
import sys

client = rarbgapi.RarbgAPI()

categories = ";".join(
    map(str, [
        rarbgapi.RarbgAPI.CATEGORY_MOVIE_H264_4K,
        rarbgapi.RarbgAPI.CATEGORY_MOVIE_H265_4K,
        rarbgapi.RarbgAPI.CATEGORY_MOVIE_H265_4K_HDR,
        rarbgapi.RarbgAPI.CATEGORY_MOVIE_FULL_BD,
        rarbgapi.RarbgAPI.CATEGORY_MOVIE_H264_1080P,
    ]))


def default_rarbg_filter(d):
    if int(d['ranked']) != 1:
        return False
    size_gb = float(d['size']) / (1024**3)
    if size_gb < 3 or size_gb > 16:
        return False
    return True

def get_torrents(search_string="",
                 download_dir="",
                 converter_name="",
                 *args,
                 **kwargs):

    dict_torrents = {}

    # RarBg
    rarbg_client = rarbgapi.RarbgAPI()

    search_string_parser = PTN()
    dict_search_string_values = search_string_parser.parse(search_string)

    # category = [rarbg_client.CATEGORY_TV_EPISODES_UHD, rarbg_client.CATEGORY_TV_EPISODES_HD, rarbg_client.CATEGORY_TV_EPISODES]
    torrent_parser = PTN()

    dict_group_torrents = {}

    # Group torrents by season, episode
    lst_torrent = rarbg_client.search(search_string=search_string, limit=100)
    if lst_torrent:
        for torrent_ in sorted(lst_torrent, key=lambda item: item.filename):

            dict_torrent_values = torrent_parser.parse(name=torrent_.filename)
            shared_items = get_shared_items(dict_search_string_values,
                                            dict_torrent_values)
            dict_torrent_values.update(torrent_._raw)

            state_keys = len(shared_items) == len(dict_search_string_values)
            state_name = str(torrent_.filename).lower().startswith(
                search_string.lower().replace(" ", "."))

            if not (state_keys
                    or state_name and "resolution" in dict_torrent_values):
                continue

            dict_torrent_values["download_dir"] = download_dir

            is_combined = False
            key = None
            if "tv" in dict_torrent_values["category"].lower():
                key = (dict_torrent_values['title'], "tv")
                is_combined = True
            elif 'season' in dict_torrent_values and 'episode' in dict_torrent_values:
                key = (dict_torrent_values['title'],
                       dict_torrent_values['season'],
                       dict_torrent_values['episode'])
            elif "movies" in "{0}".format(
                    dict_torrent_values["category"].lower()).split("/"):
                key = (dict_torrent_values['title'], "movies")
                is_combined = True

            if key:
                dict_torrent_values["key_name"] = key

                if key not in dict_group_torrents:
                    dict_group_torrents[key] = []
                dict_group_torrents[key].append(dict_torrent_values)

            if is_combined:
                break

    # Get the best resolution and converter name by every key (season, episode)
    for key_name_, lst_data_ in dict_group_torrents.items():
        lst_data_.sort(key=lambda item: item["resolution"]
                       if "resolution" in item else item["filename"])

        dict_torrent = lst_data_[0]

        if converter_name:
            for dict_torrent_ in lst_data_:

                converter_name_value_ = None
                if "excess" in dict_torrent_:
                    converter_name_value_ = dict_torrent_["excess"]

                if "group" in dict_torrent_:
                    converter_name_value_ = dict_torrent_["group"]

                if isinstance(converter_name_value_, str):
                    converter_name_value_ = [converter_name_value_]

                found = False
                for conv_name_value_ in converter_name_value_:
                    if str(conv_name_value_).endswith(converter_name):
                        found = True
                        break
                if found:
                    dict_torrent = dict_torrent_
                    break

        dict_torrents[key_name_] = dict_torrent

    return dict_torrents
Exemplo n.º 10
0
import aiohttp
import requests
import string
import asyncio
import html

load_dotenv()

DISC_TOKEN = os.getenv('DISCORD_TOKEN')
TMDB_TOKEN = os.getenv('TMDB_API_KEY')

#API instantiation
client = discord.Client()
movie = tmdbv3api.Movie()
person = tmdbv3api.Person()
rbapi = rarbgapi.RarbgAPI()

#magnet link shortener url for post method
mgnet = "http://mgnet.me/api/create"


#function which gets the magnet link from rarbg and shortens it using mgnet.me api
def getID(title):
    tmp = title
    title = ''
    for i in tmp:
        if i in string.punctuation:
            continue
        title += i
    tmp = title
    title = ''