Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 05-25-2014, 09:16 AM   #1
vinny3777
Junior Member
vinny3777 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2014
Device: Kindle Paperwhite 2nd Generation
Question Video Removal from News Feed

I am trying to remove videos from my custom news feed. I have tried everything I know about python and nothing has worked. Can someone tell me what code I need to use in order to get rid of "This video cannot be played because the JavaScript isn't enabled"

Here is the code I made:

class AdvancedUserRecipe1400969285(BasicNewsRecipe):
title = u'NBC News'
oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = True
auto_cleanup_keep = '//div[@class="thumbnail"]'
filterDuplicates = True
remove_empty_feeds = True

feeds = [

(u'Top Stories' , u'http://feeds.nbcnews.com/feeds/topstories' )
,(u'U.S. News' , u'http://feeds.nbcnews.com/feeds/usnews' )
,(u'Technology' , u'http://feeds.nbcnews.com/feeds/technology' )
,(u'Investigations' , u'http://feeds.nbcnews.com/feeds/investigations' )
,(u'Business' , u'http://feeds.nbcnews.com/feeds/business' )
,(u'Science' , u'http://feeds.nbcnews.com/feeds/science' )
,(u'Health' , u'http://feeds.nbcnews.com/feeds/health' )

]

remove_tags = [

dict(name='div', attrs={'class''^.*video.*$')}),

]









Last edited by vinny3777; 05-25-2014 at 06:48 PM.
vinny3777 is offline   Reply With Quote
Old 05-25-2014, 11:52 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 33,724
Karma: 10215826
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot use both auto_cleanup and remove_tags. If you set auto_cleanup to true then remove tags will be ignored.
kovidgoyal is online now   Reply With Quote
Advert
Old 05-26-2014, 08:59 AM   #3
vinny3777
Junior Member
vinny3777 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2014
Device: Kindle Paperwhite 2nd Generation
I tried that but then no articles came up just links and tables of contents?

Here is the new code

class AdvancedUserRecipe1400969285(BasicNewsRecipe):
title = u'NBC News'
oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = False
filterDuplicates = True
remove_empty_feeds = True

feeds = [

(u'Top Stories' , u'http://feeds.nbcnews.com/feeds/topstories' )
,(u'U.S. News' , u'http://feeds.nbcnews.com/feeds/usnews' )
,(u'Technology' , u'http://feeds.nbcnews.com/feeds/technology' )
,(u'Investigations' , u'http://feeds.nbcnews.com/feeds/investigations' )
,(u'Business' , u'http://feeds.nbcnews.com/feeds/business' )
,(u'Science' , u'http://feeds.nbcnews.com/feeds/science' )
,(u'Health' , u'http://feeds.nbcnews.com/feeds/health' )

]

remove_tags = [

dict(name='div', attrs={'class''^.*video.*$')}),

]

Please Help Kovid
vinny3777 is offline   Reply With Quote
Old 05-26-2014, 02:18 PM   #4
vinny3777
Junior Member
vinny3777 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2014
Device: Kindle Paperwhite 2nd Generation
PLease help anyone!!
vinny3777 is offline   Reply With Quote
Old 05-26-2014, 11:31 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 33,724
Karma: 10215826
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you are trying to remove tags that have the word video in their class attributes, you want

remove_tags = [

dict(name='div', attrs={'class':lambda x: x and 'video' in x.split())}),

]
kovidgoyal is online now   Reply With Quote
Advert
Old 05-30-2014, 07:55 AM   #6
vinny3777
Junior Member
vinny3777 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2014
Device: Kindle Paperwhite 2nd Generation
Did that Kovid but this is the error message that came up

calibre, version 1.37.0
ERROR: Invalid input: <p>Could not create recipe. Error:<br>invalid syntax (<string>, line 23)

Here is the code again

class AdvancedUserRecipe1400969285(BasicNewsRecipe):
title = u'NBC News'
oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = False
filterDuplicates = True
remove_empty_feeds = True

feeds = [

(u'Top Stories' , u'http://feeds.nbcnews.com/feeds/topstories' )
,(u'U.S. News' , u'http://feeds.nbcnews.com/feeds/usnews' )
,(u'Technology' , u'http://feeds.nbcnews.com/feeds/technology' )
,(u'Investigations' , u'http://feeds.nbcnews.com/feeds/investigations' )
,(u'Business' , u'http://feeds.nbcnews.com/feeds/business' )
,(u'Science' , u'http://feeds.nbcnews.com/feeds/science' )
,(u'Health' , u'http://feeds.nbcnews.com/feeds/health' )

]

remove_tags = [

dict(name='div', attrs={'class':lambda x: x and 'video' in x.split())}),

]
vinny3777 is offline   Reply With Quote
Reply

Tags
calibre, news feed, video

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty news feed bubak Recipes 4 06-14-2011 08:38 PM
How to create a NEWS Feed irshwsky Recipes 2 04-18-2011 02:54 PM
Two different formats on news feed TonytheBookworm Calibre 3 10-06-2010 12:51 PM
News feed scheduling nickredding Calibre 1 01-24-2010 08:28 PM
The New Yorker news feed yekim54 Calibre 5 05-25-2009 10:33 PM


All times are GMT -4. The time now is 05:21 AM.


MobileRead.com is a privately owned, operated and funded community.