Last active
August 29, 2015 14:02
-
-
Save davelowe/4dc9f06800ecde59e107 to your computer and use it in GitHub Desktop.
Import feed manually
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from medley.feed_importer.tasks import FeedImportTask | |
from medley.feed_importer.models import ImportedFeed | |
t = FeedImportTask() | |
# if you have a specific feed pk | |
f = ImportedFeed.objects.get(pk=1111) | |
t.taskfunc(f.feed_url, f.pk) | |
# Looping over some feeds belonging to a specific category: | |
for f in ImportedFeed.objects.filter(categories__name="Entertainment")[:10]: | |
t.taskfunc(f.feed_url, f.pk) | |
print 'Imported items for {0}'.format(f.title) | |
# Manually inspecting what's happening with each entry | |
import feedparser | |
from medley.feed_importer.processors import EntryProcessor | |
xml = t.read_feed(f.feed_url) | |
parsedfeed = feedparser.parse(xml) | |
parsedentries = parsedfeed.entries | |
proc = EntryProcessor(feed=f) | |
entry = proc.process_entry(parsedentries[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment