1 from datetime
import datetime
4 from django
.core
.management
.base
import BaseCommand
6 from couchdbkit
.exceptions
import ResourceNotFound
8 from mygpo
.core
.models
import Podcast
9 from mygpo
.directory
.models
import ExamplePodcasts
12 EXAMPLES_DOCID
= 'example_podcasts'
14 class Command(BaseCommand
):
16 def handle(self
, *args
, **options
):
18 urls
= list(map(str.strip
, fileinput
.input(args
)))
21 examples
= ExamplePodcasts
.get(EXAMPLES_DOCID
)
22 except ResourceNotFound
:
23 examples
= ExamplePodcasts()
24 examples
._id
= EXAMPLES_DOCID
26 podcasts
= filter(None, [Podcast
.for_url(url
) for url
in urls
])
27 examples
.podcast_ids
= [podcast
.get_id() for podcast
in podcasts
]
28 examples
.updated
= datetime
.utcnow()