コード例 #1
0
ファイル: hdtorrents.py プロジェクト: some-guy-23/Announced
def parse(announcement):
    global name

    if 'TV' not in announcement:
        return
    decolored = utils.strip_irc_color_codes(announcement)

    # extract required information from announcement
    torrent_title = utils.substr(decolored, '] ', ' (', True)
    torrent_id = utils.get_id(decolored, 0)

    # pass announcement to sonarr
    if torrent_id is not None and torrent_title is not None:
        download_link = get_torrent_link(
            torrent_id, utils.replace_spaces(torrent_title, '.'))

        announced = db.Announced(date=datetime.datetime.now(),
                                 title=utils.replace_spaces(
                                     torrent_title, '.'),
                                 indexer=name,
                                 torrent=download_link)
        approved = sonarr.wanted(torrent_title, download_link, name)
        if approved:
            logger.debug("Sonarr approved release: %s", torrent_title)
            snatched = db.Snatched(date=datetime.datetime.now(),
                                   title=utils.replace_spaces(
                                       torrent_title, '.'),
                                   indexer=name,
                                   torrent=download_link)
        else:
            logger.debug("Sonarr rejected release: %s", torrent_title)
コード例 #2
0
def parse(announcement):
    global name

    # extract required information from announcement
    torrent_title = utils.str_before(announcement, ' - ')
    torrent_id = utils.get_id(announcement, 1)

    # pass announcement to sonarr
    if torrent_id is not None and torrent_title is not None:
        download_link = get_torrent_link(
            torrent_id, utils.replace_spaces(torrent_title, '.'))

        announced = db.Announced(date=datetime.datetime.now(),
                                 title=utils.replace_spaces(
                                     torrent_title, '.'),
                                 indexer=name,
                                 torrent=download_link)
        approved = sonarr.wanted(torrent_title, download_link, name)
        if approved:
            logger.debug("Sonarr approved release: %s", torrent_title)
            snatched = db.Snatched(date=datetime.datetime.now(),
                                   title=utils.replace_spaces(
                                       torrent_title, '.'),
                                   indexer=name,
                                   torrent=download_link)
        else:
            logger.debug("Sonarr rejected release: %s", torrent_title)
コード例 #3
0
def wanted(title, download_link, indexer):
    global cfg
    approved = False

    logger.debug("Notifying Sonarr of release from %s: %s @ %s", indexer, title, download_link)

    headers = {'X-Api-Key': cfg['sonarr.apikey']}
    params = {
        'title': utils.replace_spaces(title, '.'),
        'downloadUrl': download_link,
        'protocol': 'Torrent',
        'publishDate': datetime.datetime.now().isoformat(),
        'indexer': indexer
    }
    requestUrl = f"{cfg['sonarr.url']}/api/release/push"

    logger.debug(f"REQ_HEADERS: {headers}")
    logger.debug(f"REQ_PARAMS:  {params}")
    logger.debug(f"REQ_URL:     {requestUrl}")

    resp = requests.post(url=requestUrl, headers=headers, json=params)
    resp_obj = resp.json()

    logger.debug(f"RESP_REQ_BODY:    {resp.request.body}")
    logger.debug(f"RESP_REQ_HEADERS: {resp.request.headers}")
    logger.debug(f"RESP_CODE:        {resp.status_code}")
    logger.debug(f"RESP_OBJ:         {resp_obj}")

    if 'approved' in resp_obj:
        logger.debug(f"FIND: 'approved' in RESP_OBJ")
        approved = resp_obj['approved']
    
    logger.debug(f"APPROVED: {approved}")

    return approved
コード例 #4
0
def notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
               pvr_name):
    if torrent_id is not None and torrent_title is not None:
        torrent_link_title = utils.replace_periods(
            utils.replace_spaces(torrent_title, '-'), '').lower()
        download_link = get_torrent_link(torrent_id, torrent_link_title)

        announced = db.Announced(date=datetime.datetime.now(),
                                 title=torrent_title,
                                 indexer=name,
                                 torrent=download_link,
                                 pvr=pvr_name)

        if delay > 0:
            logger.debug("Waiting %s seconds to check %s", delay,
                         torrent_title)
            time.sleep(delay)

        if pvr_name == 'Sonarr':
            approved = sonarr.wanted(torrent_title, download_link, name)
        elif pvr_name == 'Radarr':
            approved = radarr.wanted(torrent_title, download_link, name)

        if approved:
            logger.debug("%s approved release: %s", pvr_name, torrent_title)
            snatched = db.Snatched(date=datetime.datetime.now(),
                                   title=torrent_title,
                                   indexer=name,
                                   torrent=download_link,
                                   pvr=pvr_name)
        else:
            logger.debug("%s rejected release: %s", pvr_name, torrent_title)

    return
コード例 #5
0
ファイル: hdtorrents.py プロジェクト: some-guy-23/Announced
def get_torrent_link(torrent_id, torrent_name):
    host = ''
    if cfg['server.host'].startswith('0.0.'):
        host = 'localhost'
    else:
        host = cfg['server.host']

    download_link = "http://{}:{}/mitm/{}/{}/{}".format(
        host, cfg['server.port'], name, torrent_id,
        utils.replace_spaces(torrent_name, '.'))
    return download_link
コード例 #6
0
def parse(announcement):
    global name

    decolored = utils.strip_irc_color_codes(announcement)
    if '[Episode]' not in decolored:
        return

    # extract required information from announcement
    torrent_title = parse_torrent_title(decolored)
    if not torrent_title:
        return
    torrent_id = utils.get_id(decolored, 0)

    # pass announcement to sonarr
    if torrent_id is not None and torrent_title is not None:
        download_link = get_torrent_link(
            torrent_id, utils.replace_spaces(torrent_title, '.'))

        announced = db.Announced(date=datetime.datetime.now(),
                                 title=utils.replace_spaces(
                                     torrent_title, '.'),
                                 indexer=name,
                                 torrent=download_link)

        if delay > 0:
            logger.debug("Waiting %s seconds to check %s", delay,
                         torrent_title)
            time.sleep(delay)

        approved = sonarr.wanted(torrent_title, download_link, name)
        if approved:
            logger.debug("Sonarr approved release: %s", torrent_title)
            snatched = db.Snatched(date=datetime.datetime.now(),
                                   title=utils.replace_spaces(
                                       torrent_title, '.'),
                                   indexer=name,
                                   torrent=download_link)
        else:
            logger.debug("Sonarr rejected release: %s", torrent_title)
コード例 #7
0
def make_search(string):
    new_str = replace_spaces(string)
    add_url = new_str + "%20vs%20"
    base_url = "http://suggestqueries.google.com/complete/search?&output=toolbar&gl=fi&hl=en&q="
    url = base_url + add_url

    response = str(urllib.urlopen(url).read())
    array = re.findall("\<suggestion data=\"(.+?)\"", response)
    if array:
        new_dict = response_to_json(array)
    else:
        print("No suggestions found! for " + string)
    return new_dict
コード例 #8
0
def parse(announcement):
    global name, torrent_title
    decolored = utils.strip_irc_color_codes(announcement)

    # extract required information from decolored
    if 'NOW BROADCASTING' in decolored:
        torrent_title = utils.substr(decolored, '[ ', ' ]', True)
    torrent_id = utils.get_id(decolored, 1)

    # pass announcement to sonarr
    if torrent_id is not None and torrent_title is not None:
        download_link = get_torrent_link(
            torrent_id, utils.replace_spaces(torrent_title, '.'))

        announced = db.Announced(date=datetime.datetime.now(),
                                 title=utils.replace_spaces(
                                     torrent_title, '.'),
                                 indexer=name,
                                 torrent=download_link,
                                 pvr='Sonarr')

        if delay > 0:
            logger.debug("Waiting %s seconds to check %s", delay,
                         torrent_title)
            time.sleep(delay)

        approved = sonarr.wanted(torrent_title, download_link, name)
        if approved:
            logger.debug("Sonarr approved release: %s", torrent_title)
            snatched = db.Snatched(date=datetime.datetime.now(),
                                   title=utils.replace_spaces(
                                       torrent_title, '.'),
                                   indexer=name,
                                   torrent=download_link)
        else:
            logger.debug("Sonarr rejected release: %s", torrent_title)
        torrent_title = None
コード例 #9
0
def parse(announcement):
    global name

    decolored = utils.strip_irc_color_codes(announcement)
    if 'New Torrent Announcement: <' not in decolored:
        return
        
    # extract required information from announcement
    torrent_title = utils.replace_spaces(utils.substr(decolored, 'Name:\'', '\' uploaded', True), '.')
    torrent_id = decolored.split('/')[-1]
    
    
    if '<TV ::' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name, 'Sonarr')
    elif '<Movies ::' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name, 'Radarr')
コード例 #10
0
ファイル: revolutiontt.py プロジェクト: some-guy-23/Announced
def parse(announcement):
    global name

    decolored = utils.strip_irc_color_codes(announcement)
    if '!new ' not in decolored:
        return

    # extract required information from announcement
    torrent_title = utils.replace_spaces(
        utils.substr(decolored, '!new ', ' | ', True), '.')
    torrent_id = utils.substr(decolored, '?id=', '&', True)

    if '| TV/' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
                   'Sonarr')
    elif '| Movies/' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
                   'Radarr')
コード例 #11
0
def parse(announcement):
    global name

    decolored = utils.strip_irc_color_codes(announcement)
    if ' - http://www.iptorrents.com/details.php?id=' not in decolored:
        return

    # extract required information from announcement
    torrent_title = utils.replace_spaces(
        utils.substr(decolored, '] ', ' - http', True), '.')
    torrent_id = utils.get_id(decolored, 0)

    if 'TV/' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
                   'Sonarr')
    elif 'Movie/' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
                   'Radarr')
コード例 #12
0
def parse(announcement):
    global name

    decolored = utils.strip_irc_color_codes(announcement)
    if 'https://pretome.info/details.php' not in decolored:
        return

    # extract required information from announcement
    torrent_substr = utils.substr(decolored, '] ', ' https', True)
    torrent_title = utils.replace_spaces(
        utils.substr(torrent_substr, '', ' ::', True), '.')
    torrent_id = utils.get_id(decolored, 0)

    if 'TV|' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
                   'Sonarr')
    elif 'Movies|' in decolored:
        notify_pvr(torrent_id, torrent_title, auth_key, torrent_pass, name,
                   'Radarr')
コード例 #13
0
def wanted(title, download_link, indexer):
    global cfg
    approved = False

    logger.debug("Notifying Sonarr of release from %s: %s @ %s", indexer, title, download_link)

    headers = {'X-Api-Key': cfg['sonarr.apikey']}
    params = {
        'title': utils.replace_spaces(title, '.'),
        'downloadUrl': download_link,
        'protocol': 'Torrent',
        'publishDate': datetime.datetime.now().isoformat(),
        'indexer': indexer
    }

    resp = requests.post(url="{}/api/release/push".format(cfg['sonarr.url']), headers=headers, params=params).json()
    if 'approved' in resp:
        approved = resp['approved']

    return approved