From 8ca27d3cd78914132ba1eb7e894ca8b69e0226eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Tue, 18 Sep 2012 22:06:35 +0200 Subject: [PATCH] feed-downloader improvements --- mygpo/core/models.py | 1 + mygpo/data/feeddownloader.py | 5 ++++- mygpo/data/mimetype.py | 23 ++--------------------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/mygpo/core/models.py b/mygpo/core/models.py index b7ba5ee1..a2eca32c 100644 --- a/mygpo/core/models.py +++ b/mygpo/core/models.py @@ -42,6 +42,7 @@ class Episode(Document, SlugMixin, OldIdMixin): __metaclass__ = DocumentABCMeta title = StringProperty() + guid = StringProperty() description = StringProperty(default="") content = StringProperty(default="") link = StringProperty() diff --git a/mygpo/data/feeddownloader.py b/mygpo/data/feeddownloader.py index 99e5300f..10337b2c 100755 --- a/mygpo/data/feeddownloader.py +++ b/mygpo/data/feeddownloader.py @@ -143,8 +143,10 @@ class PodcastUpdater(object): if not url: continue + guid = parsed_episode.guid + # pop matchin episodes out of the "existing" list - matching, remaining = split_list(remaining, lambda e: url in e.urls) + matching, remaining = split_list(remaining, lambda e: (e.guid and e.guid == guid) or url in e.urls) if not matching: new_episode = Episode.for_podcast_id_url(podcast.get_id(), @@ -155,6 +157,7 @@ class PodcastUpdater(object): for episode in matching: changed = False + changed |= update_a(episode, 'guid', parsed_episode.guid or episode.guid) changed |= update_a(episode, 'title', parsed_episode.title or episode.title) changed |= update_a(episode, 'description', parsed_episode.description or episode.description) changed |= update_a(episode, 'content', parsed_episode.content or parsed_episode.description or episode.content) diff --git a/mygpo/data/mimetype.py b/mygpo/data/mimetype.py index 52059c08..47a60324 100644 --- a/mygpo/data/mimetype.py +++ b/mygpo/data/mimetype.py @@ -51,29 +51,10 @@ def get_type(mimetype): return 'audio' elif type == 'x-youtube': return 'video' + elif type == 'x-vimeo': + return 'video' return None -def check_mimetype(mimetype): - """Checks if the given mimetype can be processed by mygpo - """ - - if not mimetype: - return False - - if '/' in mimetype: - category, type = mimetype.split('/', 1) - if category in ('audio', 'video', 'image'): - return True - - # application/ogg is a valid mime type for Ogg files - # but we do not want to accept all files with application category - if type in ('ogg', ): - return True - - return False - else: - return False - def get_mimetype(mimetype, url): """Returns the mimetype; if None is given it tries to guess it""" -- 2.11.4.GIT