Exemplo n.º 1
0
def get_entries(url, source, weekday, series, team, httpproxy=None):
    "The function is used to parse feed and extract information"
    feed = parse_feed(url, set_user_agent=True, httpproxy=httpproxy)
    entries = []
    for i in feed.entries:
        entries.append({
            'source':
            source,
            'weekday':
            weekday,
            'series':
            series,
            'team':
            team,
            'title':
            i.title,
            'page_link':
            i.link,
            'pubdate':
            to_iso_utc(i.published, "%a, %d %b %Y %H:%M:%S %Z"),
            'episode':
            extract_episode(i.title),
            'download_link':
            i.enclosures[0].href,
            'link_type':
            'torrent'
        })
    return entries
Exemplo n.º 2
0
def checkup(args):
    config = merge_args_yaml(args)
    initialize_db()
    initialize_tasks()
    for item_key in config['tasks']:
        item = Item(config, item_key)
        if config['chosenitem'] != None:
            if not item.series in config['chosenitem']:
                continue
        if config['usenet']:
            entries = item.get_entries()
            for entry in entries:
                if not has_entry(entry) and calculate_timegone(
                        entry['pubdate']) < 90 * 86400:
                    if entry['episode'] != None:
                        update_db(entry)
                    else:
                        item.write_sh(entry)

        if config['usedatebase']:
            episode_nums = set()
            for root, dirs, files in os.walk(
                    os.path.join(config['download_path'], item_key)):
                for name in files:
                    episode_nums.add(extract_episode(name))
            episode_nums.discard(None)
            print(item_key, episode_nums)
            entries = query_all_by_series(item.series)
            for entry in entries:
                if entry['episode'] not in episode_nums:
                    item.write_sh(entry)
Exemplo n.º 3
0
def checkup(args):
    config = merge_args_yaml(args)
    initialize_db()
    initialize_tasks()
    for item_key in config['tasks']:
        item = Item(config,item_key)
        if config['chosenitem'] != None:
            if not item.series in config['chosenitem']:
                continue
        if config['usenet']:
            entries = item.get_entries()
            for entry in entries:
                if not has_entry(entry) and calculate_timegone(entry['pubdate']) < 90*86400:
                    if entry['episode'] != None:
                        update_db(entry)
                    else:
                        item.write_sh(entry)

        if config['usedatebase']:
            episode_nums = set()
            for root,dirs,files in os.walk(os.path.join(config['download_path'],item_key)):
                for name in files:
                    episode_nums.add(extract_episode(name))
            episode_nums.discard(None)
            print(item_key,episode_nums)
            entries = query_all_by_series(item.series)
            for entry in entries:
                if entry['episode'] not in episode_nums:
                    item.write_sh(entry)
def get_entries(url,source,weekday,series,team,httpproxy=None):
    page = parse_page(url, set_user_agent=True, httpproxy=httpproxy)
    entries = []
    soup = BeautifulSoup(page.content, 'html.parser')
    items = soup.find('tbody',id='data_list').find_all('tr')
    for i in items:
        title = i.find('td',style="text-align:left;").text.strip()
        download_link = i.find('td',style="text-align:left;").a['href']
        datetuple = re.search('(\w{4})/(\w{2})/(\w{2})',download_link).groups()
        timetuple = re.search('(\w{2}):(\w{2})',
            i.find_all('td')[-1].text).groups()
        pubdate_local = "%s %s:00 +0800" % (' '.join(reversed(datetuple)),
            ':'.join(timetuple))
        entries.append({
            'source':source,
            'weekday':weekday,
            'series':series,
            'team':team,
            'title': title,
            'page_link': ('http://share.xfsub.com:88/' +
                i.find('a',target="_blank")['href']),
            'pubdate': to_iso_utc(pubdate_local,"%d %m %Y %H:%M:%S %z"),
            'episode': extract_episode(title),
            'download_link': download_link,
            'link_type': 'torrent'
            })
    return entries
Exemplo n.º 5
0
def get_entries(url,source,weekday,series,team,httpproxy=None):
    "The function is used to parse feed and extract information"
    feed = parse_feed(url, set_user_agent=True, httpproxy=httpproxy)
    entries = []
    for i in feed.entries:
        entries.append({
            'source':source,
            'weekday':weekday,
            'series':series,
            'team':team,
            'title': i.title,
            'page_link': i.link,
            'pubdate': to_iso_utc(i.published,"%a, %d %b %Y %H:%M:%S %Z"),
            'episode': extract_episode(i.title),
            'download_link': i.enclosures[0].href,
            'link_type': 'torrent'
            })
    return entries
Exemplo n.º 6
0
def get_episodenums_by_series(series):
    """获得episodenums

    Args:
        series  type: string

    Returns:
        episode_nums    type: set
    """
    episode_nums = set()
    with sqlite3.connect(DATEBASE) as conn:
        cur = conn.cursor()
        cur.execute('SELECT title FROM updates WHERE series=?;', (series, ))
        t = cur.fetchall()
        from rssparser.tackles import extract_episode
        for i in t:
            episode_nums.add(extract_episode(name))
    episode_nums.discard(None)
    return episode_nums
Exemplo n.º 7
0
def get_episodenums_by_series(series):
    """获得episodenums

    Args:
        series  type: string

    Returns:
        episode_nums    type: set
    """
    episode_nums = set()
    with sqlite3.connect(DATEBASE) as conn:
        cur = conn.cursor()
        cur.execute('SELECT title FROM updates WHERE series=?;',(series,))
        t = cur.fetchall()
        from rssparser.tackles import extract_episode
        for i in t:
            episode_nums.add(extract_episode(name))
    episode_nums.discard(None)
    return episode_nums
Exemplo n.º 8
0
def get_entries(url, source, weekday, series, team, httpproxy=None):
    page = parse_page(url, set_user_agent=True, httpproxy=httpproxy)
    entries = []
    soup = BeautifulSoup(page.content, 'html.parser')
    items = soup.find('tbody', id='data_list').find_all('tr')
    for i in items:
        title = i.find('td', style="text-align:left;").text.strip()
        download_link = i.find('td', style="text-align:left;").a['href']
        datetuple = re.search('(\w{4})/(\w{2})/(\w{2})',
                              download_link).groups()
        timetuple = re.search('(\w{2}):(\w{2})',
                              i.find_all('td')[-1].text).groups()
        pubdate_local = "%s %s:00 +0800" % (' '.join(
            reversed(datetuple)), ':'.join(timetuple))
        entries.append({
            'source':
            source,
            'weekday':
            weekday,
            'series':
            series,
            'team':
            team,
            'title':
            title,
            'page_link': ('http://share.xfsub.com:88/' +
                          i.find('a', target="_blank")['href']),
            'pubdate':
            to_iso_utc(pubdate_local, "%d %m %Y %H:%M:%S %z"),
            'episode':
            extract_episode(title),
            'download_link':
            download_link,
            'link_type':
            'torrent'
        })
    return entries