Exemplo n.º 1
0
def get_content_vars(date):
    image_title = image_template % date_vars(date)
    url = 'http://hu.wikipedia.org/w/index.php?title=Sablon:%s&action=raw' % encode_title(
        image_title)
    content = feed.get_html(url, date).decode('utf-8')
    image = re.sub('<noinclude>.*?</noinclude>', '', content)

    image = encode_title(image)
    url = 'http://hu.wikipedia.org/w/api.php?action=query&titles=File:%s&prop=imageinfo&iiurlwidth=350px&iiprop=url&format=xml' % image
    content = feed.get_html(url, date).decode('utf-8')
    try:
        image = re.search('thumburl="(.*?)"', content).group(1)
    except AttributeError:
        image = ''
    try:
        page = re.search('descriptionurl="(.*?)"', content).group(1)
    except AttributeError:
        page = ''

    desc_title = desc_template % date_vars(date)
    url = 'http://hu.wikipedia.org/w/index.php?title=Sablon:%s&action=render' % encode_title(
        desc_title)
    desc = feed.get_html(url, date).decode('utf-8')

    return {
        'image': image,
        'page': page,
        'desc': desc,
    }
Exemplo n.º 2
0
def get_content_vars(date):
    image_title = image_template % date_vars(date)
    url = 'http://hu.wikipedia.org/w/index.php?title=Sablon:%s&action=raw' % encode_title(image_title)
    content = feed.get_html(url, date).decode('utf-8')
    image = re.sub('<noinclude>.*?</noinclude>', '', content)
    
    image = encode_title(image)
    url = 'http://hu.wikipedia.org/w/api.php?action=query&titles=File:%s&prop=imageinfo&iiurlwidth=350px&iiprop=url&format=xml' % image
    content = feed.get_html(url, date).decode('utf-8')
    try:
        image = re.search('thumburl="(.*?)"', content).group(1)
    except AttributeError:
        image = ''
    try:
        page = re.search('descriptionurl="(.*?)"', content).group(1)
    except AttributeError:
        page = ''
    
    desc_title = desc_template % date_vars(date)
    url = 'http://hu.wikipedia.org/w/index.php?title=Sablon:%s&action=render' % encode_title(desc_title)
    desc = feed.get_html(url, date).decode('utf-8')
    
    return {
        'image': image,
        'page' : page,
        'desc' : desc,
    }
Exemplo n.º 3
0
def get_title(date):
    api_call = 'http://hu.wikipedia.org/w/api.php?action=expandtemplates&text={{Sablon:%(page)s|%(year)s|%(week)s|%(n)s}}&format=yaml'
    url = api_call % date_vars(date, {
        'page': encode_title(u'Kezdõlapra került szócikkek listája'),
    })
    yaml = feed.get_html(url, date).decode('utf-8')
    m = re.search(r'"\*":"(.+?)"', yaml, re.MULTILINE)
    title_json = m.group(1)
    title = re.sub(r'\\u([\da-f]{4})', unicode_decode, title_json)
    return title
Exemplo n.º 4
0
def get_title(date):
    api_call = 'http://hu.wikipedia.org/w/api.php?action=expandtemplates&text={{Sablon:%(page)s|%(year)s|%(week)s|%(n)s}}&format=yaml'
    url = api_call % date_vars(
        date, {
            'page': encode_title(u'Kezdõlapra került szócikkek listája'),
        })
    yaml = feed.get_html(url, date).decode('utf-8')
    m = re.search(r'"\*":"(.+?)"', yaml, re.MULTILINE)
    title_json = m.group(1)
    title = re.sub(r'\\u([\da-f]{4})', unicode_decode, title_json)
    return title
Exemplo n.º 5
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days=1)
    dates = [today - one_day * x for x in range(settings["time_range"])]

    def is_right_day(date):
        return date.isocalendar()[2] in settings["days_of_week"]

    dates = filter(is_right_day, dates)

    items = []
    for date in dates:
        items.append(
            {
                "title": u"%(monthname)s %(day)d: Ünnepek" % date_vars(date),
                "url": "http://hu.wikipedia.org/wiki/#%(month)d/%(day)d" % date_vars(date),
                "content": get_content(date),
            }
        )
    feed.rss(items)
    feed.save()
Exemplo n.º 6
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days=1)
    dates = [today - one_day * x for x in range(settings['time_range'])]

    def is_right_day(date):
        return date.isocalendar()[2] in settings['days_of_week']

    dates = filter(is_right_day, dates)

    items = []
    for date in dates:
        items.append({
            'title':
            u'%(monthname)s %(day)d: Ünnepek' % date_vars(date),
            'url':
            'http://hu.wikipedia.org/wiki/#%(month)d/%(day)d' %
            date_vars(date),
            'content':
            get_content(date),
        })
    feed.rss(items)
    feed.save()
Exemplo n.º 7
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days = 1)
    dates = [today - one_day*x for x in range(settings['time_range'])]
    
    def is_right_day(date):
        return date.isocalendar()[2] in settings['days_of_week']
    dates = filter(is_right_day, dates)    
    
    items = []
    for date in dates:
        items.append({
            'title'  : u'%(monthname)s %(day)d: Évfordulók' % date_vars(date),
            'url'    : 'http://hu.wikipedia.org/wiki/#%(years1)d/%(month)d/%(day)d' % date_vars(date),
            'content': get_content(date),
        })
    feed.rss(items)
    feed.save()
Exemplo n.º 8
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days = 1)
    dates = [today - one_day*x for x in range(settings['time_range'])]
    
    def is_right_day(date):
        return date.isocalendar()[2] in settings['days_of_week']
    dates = filter(is_right_day, dates)
    
    items = []
    for date in dates:
        title = get_title(date)
        items.append({
            'title'  : u'%(week)d. hét / %(n)d.: %(title)s' % date_vars(date, {'title': title}),
            'url'    : 'http://hu.wikipedia.org/wiki/%s' % encode_title(title),
            'content': get_content(date),
        })
    feed.rss(items)
    feed.save()
Exemplo n.º 9
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days = 1)
    dates = [today - one_day*x for x in range(settings['time_range'])]
    
    def is_right_day(date):
        return date.isocalendar()[2] in settings['days_of_week']
    dates = filter(is_right_day, dates)    
    
    items = []
    for date in dates:
        content_vars = get_content_vars(date)
        items.append({
            'title'  : u'Nap képe (%(year)d. %(monthname)s %(day)d.)' % date_vars(date),
            'url'    : content_vars['page'],
            'content': html_template % content_vars,
        })
    feed.rss(items)
    feed.save()
Exemplo n.º 10
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days=1)
    dates = [today - one_day * x for x in range(settings['time_range'])]

    def is_right_day(date):
        return date.isocalendar()[2] in settings['days_of_week']

    dates = filter(is_right_day, dates)

    items = []
    for date in dates:
        content_vars = get_content_vars(date)
        items.append({
            'title':
            u'Nap képe (%(year)d. %(monthname)s %(day)d.)' % date_vars(date),
            'url':
            content_vars['page'],
            'content':
            html_template % content_vars,
        })
    feed.rss(items)
    feed.save()
Exemplo n.º 11
0
def main():
    today = datetime.date.today()
    one_day = datetime.timedelta(days=1)
    dates = [today - one_day * x for x in range(settings['time_range'])]

    def is_right_day(date):
        return date.isocalendar()[2] in settings['days_of_week']

    dates = filter(is_right_day, dates)

    items = []
    for date in dates:
        title = get_title(date)
        items.append({
            'title':
            u'%(week)d. hét / %(n)d.: %(title)s' %
            date_vars(date, {'title': title}),
            'url':
            'http://hu.wikipedia.org/wiki/%s' % encode_title(title),
            'content':
            get_content(date),
        })
    feed.rss(items)
    feed.save()
Exemplo n.º 12
0
def get_content(date):
    title = template_title % date_vars(date)
    url = 'http://hu.wikipedia.org/w/index.php?title=Sablon:%s&action=render' % encode_title(
        title)
    content = feed.get_html(url, date).decode('utf-8')
    return content
Exemplo n.º 13
0
def get_content(date):
    title = template_title % date_vars(date)
    url = 'http://hu.wikipedia.org/w/index.php?title=Sablon:%s&action=render' % encode_title(title)
    content = feed.get_html(url, date).decode('utf-8')
    return content