| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
import re |
| 4 |
|
| 5 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 6 |
|
| 7 |
|
| 8 |
class VillageVoice(BasicNewsRecipe): |
| 9 |
title = 'Village Voice' |
| 10 |
feeds = [ |
| 11 |
('Complete Issue', 'http://villagevoice.com/syndication/issue'), |
| 12 |
('News', 'http://villagevoice.com/syndication/section/news'), |
| 13 |
('Music', 'http://villagevoice.com/syndication/section/music'), |
| 14 |
('Movies', 'http://villagevoice.com/syndication/section/film'), |
| 15 |
# ("Restaurants", "http://villagevoice.com/syndication/section/dining"), |
| 16 |
# ("Music Events", "http://villagevoice.com/syndication/events?type=music"), |
| 17 |
# ("Calendar Events", "http://villagevoice.com/syndication/events"), |
| 18 |
# ("Promotional Events", "http://villagevoice.com/syndication/promoEvents"), |
| 19 |
# ("Restaurant Guide", "http://villagevoice.com/syndication/restaurants/search") |
| 20 |
] |
| 21 |
|
| 22 |
auto_cleanup = True |
| 23 |
max_articles_per_feed = 50 |
| 24 |
masthead_url = 'http://assets.villagevoice.com/img/citylogo.png' |
| 25 |
language = 'en' |
| 26 |
__author__ = 'Barty' |
| 27 |
|
| 28 |
seen_urls = [] |
| 29 |
|
| 30 |
# village voice breaks the article up into multiple pages, so |
| 31 |
# parse page and grab the print url |
| 32 |
|
| 33 |
url_regex = re.compile(r'\/content\/printVersion\/\d+', re.I) |
| 34 |
|
| 35 |
def print_version(self, url): |
| 36 |
if url in self.seen_urls: |
| 37 |
return None |
| 38 |
self.seen_urls.append(url) |
| 39 |
soup = self.index_to_soup(url) |
| 40 |
atag = soup.find('a', attrs={'href': self.url_regex}) |
| 41 |
if atag is None: |
| 42 |
self.log('Warning: no print url found for ' + url) |
| 43 |
else: |
| 44 |
m = self.url_regex.search(atag['href']) |
| 45 |
if m: |
| 46 |
url = 'http://www.villagevoice.com' + m.group(0) |
| 47 |
return url |