2 import urllib
.request
, urllib
.error
, urllib
.parse
3 from optparse
import make_option
5 from mygpo
.data
import delicious
6 from mygpo
.maintenance
.management
.podcastcmd
import PodcastCommand
12 class Command(PodcastCommand
):
14 Adds tags from the webservice delicious.com to podcasts
16 Podcasts are specified either by URL or the --toplist and --random
17 parameter. The delicious webservice is queried for the podcasts' websites.
18 The returned tags are added to the podcasts for the 'delicious' source.
21 def handle(self
, *args
, **options
):
23 fetch_queue
= self
.get_podcasts()
26 if not p
or not p
.link
:
29 # we don't want to spam delicious
33 f
= urllib
.request
.urlopen(p
.link
)
34 except urllib
.error
.HTTPError
:
37 tags
= delicious
.get_tags(f
.url
)
39 self
.update(podcast
=p
, tags
=tags
)
41 def update(self
, podcast
, tags
):
42 podcast
.tags
[SOURCE
] = tags