3 from optparse
import make_option
5 from mygpo
.decorators
import repeat_on_conflict
6 from mygpo
.core
.models
import Podcast
7 from mygpo
.data
import delicious
8 from mygpo
.maintenance
.management
.podcastcmd
import PodcastCommand
9 from mygpo
.db
.couchdb
.podcast
import reload_podcast
14 class Command(PodcastCommand
):
16 Adds tags from the webservice delicious.com to podcasts
18 Podcasts are specified either by URL or the --toplist and --random
19 parameter. The delicious webservice is queried for the podcasts' websites.
20 The returned tags are added to the podcasts for the 'delicious' source.
23 def handle(self
, *args
, **options
):
25 fetch_queue
= self
.get_podcasts()
28 if not p
or not p
.link
:
31 # we don't want to spam delicious
35 f
= urllib2
.urlopen(p
.link
)
36 except urllib2
.HTTPError
:
39 tags
= delicious
.get_tags(f
.url
)
41 self
.update(podcast
=p
, tags
=tags
)
44 @repeat_on_conflict(['podcast'], reload_f
=reload_podcast
)
45 def update(self
, podcast
, tags
):
46 podcast
.tags
[SOURCE
] = tags