コード例 #1
0
ファイル: sovsekretno.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    if channel != 'Совершенно секретно':
        return []

    descriptions = _Descriptions()
    sched = schedule.Schedule(tz, _source_tz)

    tabs = _fetch(_URL)[3]
    for day, tab in zip(tabs[0], tabs[2:]):
        a = day[0]
        date = a.text.strip() + ' ' + a[0].text.strip()
        sched.set_date(dateutil.parse_date(date, '%A %d %B'))
        for tv in itertools.chain(*(x[1:] for x in tab)):
            event = tv[0]
            sched.set_time(event[0].text)
            info = event[1]
            p = info[0]
            title = info[1].text
            descr = p.text.rstrip()
            if title:
                sched.set_title(title.lstrip())
            else:
                sched.set_title(descr)
                descr = ''
            descr += ('\n' + p[0].text.strip() + '\n' +
                      descriptions.get(tv[1]))
            sched.set_descr(descr)
    return sched.pop()
コード例 #2
0
ファイル: vsetv.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    ch_code = channel_code.get(channel)
    if ch_code is None:
        return []

    url = 'schedule_channel_' + ch_code + '_week.html'

    sched = schedule.Schedule(tz, _source_tz)
    event_info = _EventInfo()
    doc = _fetch(url)
    for div in main(doc)[6:]:
        if div.get('class') == 'sometitle':
            date = dateutil.parse_date(div[0][0][0].text, '%A, %d %B')
            sched.set_date(date)
        else:
            for subd in div:
                subd_class = subd.get('class')
                if subd_class == 'time':
                    now = datetime.datetime.now(tz)
                    elapsed = now - sched.set_time(subd.text)
                elif subd_class == 'prname2':
                    a = subd.find('a')
                    if a is None:
                        title = (subd.text
                                 if len(subd) == 0 else subd[-1].tail[1:])
                        sched.set_title(title)
                    else:
                        title, foreign_title, descr = (event_info.get(
                            a, elapsed > _elapsed_limit))
                        sched.set_title(title)
                        if foreign_title:
                            sched.set_foreign_title()
                        if descr:
                            sched.set_descr(descr)
    return sched.pop()
コード例 #3
0
ファイル: viasat.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    ch_code = channel_code.get(channel)
    if ch_code is None:
        return []

    sched = schedule.Schedule(tz, _source_tz)

    url = _URL.format(ch_code)
    doc = lxml.etree.fromstring(requests.get(url).content, _parser)
    prog = doc[1][0][5][0][3][0][1][0]

    new_date = False
    for div in prog[0][1]:
        if len(div) == 0:
            new_date = True
        elif new_date:
            new_date = False
            date_str = div[0][0][1][0].text
            date = dateutil.parse_date(date_str, '%a, %d. %b')
            sched.set_date(date)
        else:
            sched.set_time(div[0].text)
            h3 = div[-1][-3][0]
            if len(h3) == 0:
                title = h3.text
            else:
                sched.set_foreign_title()
                title = h3[0].text
                title = title[1:-1]
            sched.set_title(title.rstrip())
            sched.set_descr(h3.tail)
    return sched.pop()
コード例 #4
0
ファイル: 2x2.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    if channel != '2x2':
        return []

    sched = schedule.Schedule(tz, _source_tz)
    event_info = _EventInfo()

    body = _fetch(_SCHED_URL)
    tab_list = body[1][0]
    days = (x[0] for x in tab_list)
    tabs = (x[0] for x in tab_list.getnext().getnext())

    for day, tab in zip(days, tabs):
        d = dateutil.parse_date(day[-2].text + day[-1].text, '%a%d %B')
        sched.set_date(d)
        for row in tab:
            it = row.iterchildren()
            time = next(it)[0][0].text
            title, descr = event_info.get(row)
            if title is None:
                next(it)
                title = next(it)[0].text
            if title is not None:
                sched.set_time(time)
                sched.set_title(title)
                sched.set_descr(descr)
    return sched.pop()
コード例 #5
0
ファイル: oruzhie.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    if channel != 'Оружие':
        return []

    sched = schedule.Schedule(tz, _source_tz)
    descriptions = _Descriptions()

    for sch in _fetch(_SCHED_URL)[2:]:
        d = dateutil.parse_date(sch[0].text, '%A, %d %B')
        sched.set_date(d)
        for row in sch[1]:
            it = row.iterchildren()
            sched.set_time(next(it)[0].text)
            a = next(it)[0][0][0][0][1]
            sched.set_title(a.text)
            sched.set_descr((descriptions.get(a)))
    return sched.pop()
コード例 #6
0
ファイル: k1.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    if channel != 'К1':
        return []

    sched = schedule.Schedule(tz, _source_tz)
    descriptions = _Descriptions()

    tables = (x[0][0] for x in _get_sched('uk')[2::5])
    for info, events in zip(_get_sched('ru')[::5], tables):
        d = dateutil.parse_date(info[0][-1].text, '%A, %d %B')
        sched.set_date(d)
        for event in events:
            it = event.iterchildren()
            sched.set_time(next(it)[0].text)
            a = next(it)[0]
            sched.set_title(a.text)
            descr = descriptions.get(a)
            if descr:
                sched.set_descr(descr)
    return sched.pop()
コード例 #7
0
def get_schedule(channel, tz):
    if channel != 'РЕН ТВ':
        return []

    sched = schedule.Schedule(tz, _source_tz)
    descriptions = _Descriptions()

    for date_row in _fetch(_SCHED_URL)[3][0][0][1]:
        it = date_row.iterchildren()
        div = next(it)[0][0]
        date = div.text + ' ' + div.tail
        sched.set_date(dateutil.parse_date(date, '%a %d %B'))

        for info in (x[1] for x in next(it)):
            it = info.iterchildren()
            sched.set_time(next(it)[0][0].text)
            a = next(it)[0][1]
            sched.set_title(a.text)
            descr = descriptions.get(a)
            if descr:
                sched.set_descr(descr)
    return sched.pop()
コード例 #8
0
ファイル: firstauto.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    if channel != 'Перший автомобільний':
        return []

    sched = schedule.Schedule(tz, _source_tz)
    descriptions = _Descriptions()

    days = _fetch(_SCHED_URL)
    for day, table in zip(days, days.getnext()):
        d = dateutil.parse_date(day[0].text + day[1].text, '%a%d %B')
        sched.set_date(d)
        for row in (x for x in table if len(x) > 1):
            it = row.iterchildren()
            sched.set_time(next(it).text)
            inner = next(it)[0]
            if len(inner) == 0:
                sched.set_title(inner.text)
            else:
                a = inner[0]
                sched.set_title(a.text)
                sched.set_descr
                sched.set_descr(descriptions.get(a))
    return sched.pop()
コード例 #9
0
ファイル: zvezda.py プロジェクト: eugene-a/TvSchedule
def get_schedule(channel, tz):
    if channel != 'Звезда':
        return []

    descriptions = _Descriptions()
    sched = schedule.Schedule(tz, _source_tz)

    table = _fetch(_SCHED_URL)[0]
    it = itertools.islice(table, 3, None, 2)
    row1 = next(it)
    days = (x[0] for x in row1[0][0][0][1:])
    row2 = next(it)
    tabs = (x[0] for x in row2[0])
    for day, tab in zip(days, tabs):
        d = dateutil.parse_date(day[0][0][0].text + day[1][0].text, '%a%d.%m')
        sched.set_date(d)
        for event in tab:
            it = event.iterchildren()
            sched.set_time(next(it).text)
            a = next(it)[0]
            sched.set_title(_get_leaf(a).text)
            sched.set_descr(descriptions.get(a))
    return sched.pop()