From 31534f3dd27b17a92333850af7fbe24fb8e99a47 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 14 Sep 2011 15:14:06 -0600 Subject: [PATCH] Fix #850382 (Updated recipe for twitch films) --- recipes/icons/twitchfilms.png | Bin 0 -> 200 bytes recipes/twitchfilms.recipe | 54 +++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 recipes/icons/twitchfilms.png diff --git a/recipes/icons/twitchfilms.png b/recipes/icons/twitchfilms.png new file mode 100644 index 0000000000000000000000000000000000000000..1a958eb4d17cc0aeec82b0ca0c34499ce4ed97be GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1qliWC@3fx7#KJ>I0OU) zBqSsh6cp6g*Z24LuV24@|Ni~w&!4}4|Ni^;@Bjb*U-d{i6sRZI)5S5QVoq|x0hT5n z9X&lJhqkZv3NtuTGWGx!#S2bQeDv>seh0IM;P2n|39}mC{+DMpX#V;)pLNBFcxHp< t&-Nj_umA5C(0mqZt-zz!!7IVQu=kbpzr>6s4}iuqc)I$ztaD0e0s!s$O$7h| literal 0 HcmV?d00001 diff --git a/recipes/twitchfilms.recipe b/recipes/twitchfilms.recipe index 681eb05aba..dab0643410 100644 --- a/recipes/twitchfilms.recipe +++ b/recipes/twitchfilms.recipe @@ -1,12 +1,9 @@ -#!/usr/bin/env python - __license__ = 'GPL v3' -__copyright__ = '2009, Darko Miletic ' +__copyright__ = '2009-2011, Darko Miletic ' ''' -twitchfilm.net/site/ +twitchfilm.net/news/ ''' from calibre.web.feeds.news import BasicNewsRecipe -from calibre.ebooks.BeautifulSoup import Tag class Twitchfilm(BasicNewsRecipe): title = 'Twitch Films' @@ -15,29 +12,46 @@ class Twitchfilm(BasicNewsRecipe): oldest_article = 30 max_articles_per_feed = 100 no_stylesheets = True - use_embedded_content = True + use_embedded_content = False encoding = 'utf-8' publisher = 'Twitch' + masthead_url = 'http://twitchfilm.com/img/logo.png' category = 'twitch, twitchfilm, movie news, movie reviews, cult cinema, independent cinema, anime, foreign cinema, geek talk' - language = 'en' - - lang = 'en-US' + language = 'en' conversion_options = { - 'comment' : description - , 'tags' : category - , 'publisher' : publisher - , 'language' : lang - , 'pretty_print' : True + 'comment' : description + , 'tags' : category + , 'publisher': publisher + , 'language' : language } - remove_tags = [dict(name='div', attrs={'class':'feedflare'})] + keep_only_tags=[dict(attrs={'class':'asset-header'})] + remove_tags_after=dict(attrs={'class':'asset-body'}) + remove_tags = [ dict(name='div', attrs={'class':['social','categories']}) + , dict(attrs={'id':'main-asset'}) + , dict(name=['meta','link','iframe','embed','object']) + ] - feeds = [(u'News', u'http://feedproxy.google.com/TwitchEverything')] + feeds = [(u'News', u'http://feeds.twitchfilm.net/TwitchEverything')] def preprocess_html(self, soup): - mtag = Tag(soup,'meta',[('http-equiv','Content-Type'),('context','text/html; charset=utf-8')]) - soup.head.insert(0,mtag) - soup.html['lang'] = self.lang - return self.adeify_images(soup) + for item in soup.findAll(style=True): + del item['style'] + for item in soup.findAll('a'): + limg = item.find('img') + if item.string is not None: + str = item.string + item.replaceWith(str) + else: + if limg: + item.name = 'div' + item.attrs = [] + else: + str = self.tag_to_string(item) + item.replaceWith(str) + for item in soup.findAll('img'): + if not item.has_key('alt'): + item['alt'] = 'image' + return soup