コード例 #1
0
ファイル: html.php プロジェクト: thawkins/torrentwatch-x
function show_torrent_html($item, $feed, $feedName, $alt, $torHash, $matched, $id)
{
    global $html_out, $test_run, $config_values;
    $guess = guess_match($item['title']);
    if ($config_values['Settings']['Episodes Only'] == 1 && ($guess['episode'] == 'noShow' || !$guess)) {
        return;
    }
    if (!$config_values['Settings']['Disable Hide List']) {
        if (isset($config_values['Hidden'][strtolower(trim(strtr($guess['key'], array(":" => "", "," => "", "'" => "", "." => " ", "_" => " "))))])) {
            return;
        }
    }
    if (($matched == "cachehit" || $matched == "downloaded" || $matched == "match") && $config_values['Settings']['Client'] != 'folder') {
        $torInfo['dlStatus'] = 'to_check';
        $torInfo['stats'] = 'Waiting for client data...';
        $torInfo['clientID'] = $torHash;
        if (isset($torInfo['dlStatus'])) {
            $matched = $torInfo['dlStatus'];
        }
    }
    // add word-breaking flags after each period
    $title = preg_replace('/\\./', '.­', $item['title']);
    // Copy feed cookies to item
    $ulink = get_torrent_link($item);
    if (($pos = strpos($feed, ':COOKIE:')) !== False) {
        $ulink .= substr($feed, $pos);
    }
    ob_start();
    require 'templates/feed_item.tpl';
    $html_out .= ob_get_contents();
    ob_end_clean();
}
コード例 #2
0
ファイル: feeds.php プロジェクト: thawkins/torrentwatch-x
function check_for_torrent(&$item, $key, $opts)
{
    global $matched, $test_run, $config_values;
    if (!(strtolower($item['Feed']) == 'all' || $item['Feed'] === '' || $item['Feed'] == $opts['URL'])) {
        return;
    }
    $rs = $opts['Obj'];
    $title = strtolower($rs['title']);
    switch (_isset($config_values['Settings'], 'MatchStyle')) {
        case 'simple':
            $hit = $item['Filter'] != '' && strpos(strtr($title, " .", "__"), strtr(strtolower($item['Filter']), " .", "__")) === 0 && ($item['Not'] == '' or my_strpos($title, strtolower($item['Not'])) === FALSE) && ($item['Quality'] == 'All' or $item['Quality'] == '' or my_strpos($title, strtolower($item['Quality'])) !== FALSE);
            break;
        case 'glob':
            $hit = $item['Filter'] != '' && fnmatch(strtolower($item['Filter']), $title) && ($item['Not'] == '' or !fnmatch(strtolower($item['Not']), $title)) && ($item['Quality'] == 'All' or $item['Quality'] == '' or strpos($title, strtolower($item['Quality'])) !== FALSE);
            break;
        case 'regexp':
        default:
            $hit = $item['Filter'] != '' && preg_match('/\\b' . strtolower(str_replace(' ', '[\\s._]', $item['Filter'])) . '\\b/', $title) && ($item['Not'] == '' or !preg_match('/' . strtolower($item['Not']) . '/', $title)) && ($item['Quality'] == 'All' or $item['Quality'] == '' or preg_match('/' . strtolower($item['Quality']) . '/', $title));
            break;
    }
    if (strtolower($item['Filter']) == "any") {
        $hit = 1;
        $any = 1;
    }
    if ($hit) {
        $guess = guess_match($title, TRUE);
    }
    if ($hit && episode_filter($guess, $item['Episodes']) == true) {
        $matched = 'match';
        if (preg_match('/^\\d+p$/', $item['Episode'])) {
            $item['Episode'] = preg_replace('/^(\\d+)p/', '\\1', $item['Episode']);
            $PROPER = 1;
        }
        if (check_cache($rs['title'])) {
            if (!$any && _isset($config_values['Settings'], 'Only Newer') == 1) {
                if (!empty($guess['episode']) && preg_match('/^(\\d+)x(\\d+)p?$|^(\\d{8})p?$/i', $guess['episode'], $regs)) {
                    if (isset($regs[3]) && preg_match('/^(\\d{8})$/', $regs[3]) && $item['Episode'] >= $regs[3]) {
                        _debug($item['Name'] . ": " . $item['Episode'] . ' >= ' . $regs[3] . "\r\n", 1);
                        $matched = "old";
                        return FALSE;
                    } else {
                        if (isset($regs[1]) && preg_match('/^(\\d{1,3})$/', $regs[1]) && $item['Season'] > $regs[1]) {
                            _debug($item['Name'] . ": " . $item['Season'] . ' > ' . $regs[1] . "\r\n", 1);
                            $matched = "old";
                            return FALSE;
                        } else {
                            if (isset($regs[2]) && preg_match('/^(\\d{1,3})$/', $regs[1]) && $item['Season'] == $regs[1] && $item['Episode'] >= $regs[2]) {
                                if (!preg_match('/proper|repack|rerip/i', $rs['title'])) {
                                    _debug($item['Name'] . ": " . $item['Episode'] . ' >= ' . $regs[2] . "\r\n", 1);
                                    $matched = "old";
                                    return FALSE;
                                } else {
                                    if ($PROPER == 1) {
                                        _debug("Allready downloaded this Proper, Repack or Rerip of " . $item['Name'] . " {$regs['1']}x{$regs['2']}{$regs['3']}\r\n");
                                        $matched = "old";
                                        return FALSE;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if ($guess['episode'] == 'fullSeason') {
                        $matched = "season";
                        return FALSE;
                    } else {
                        if ($guess['episode'] != 'noShow' && !preg_match('/^(\\d{1,2} \\d{1,2} \\d{2,4})$/', $guess['episode']) || $config_values['Settings']['Require Episode Info'] == 1) {
                            _debug("{$item} is not in a workable format.");
                            $matched = "nomatch";
                            return FALSE;
                        }
                    }
                }
            }
            _debug('Match found for ' . $rs['title'] . "\n");
            if ($test_run) {
                $matched = 'test';
                return;
            }
            if ($link = get_torrent_link($rs)) {
                $response = client_add_torrent($link, NULL, $rs['title'], $opts['URL'], $item);
                if (preg_match('/^Error:/', $response)) {
                    _debug("Failed adding torrent {$link}\n", -1);
                    return FALSE;
                } else {
                    add_cache($rs['title']);
                }
            } else {
                _debug("Unable to find URL for " . $rs['title'] . "\n", -1);
                $matched = "nourl";
            }
        }
    }
}