def get_subscribed_podcasts(self): """ Returns all subscribed podcasts for the device The attribute "url" contains the URL that was used when subscribing to the podcast """ from mygpo.db.couchdb.podcast_state import get_subscribed_podcast_states_by_device states = get_subscribed_podcast_states_by_device(self) return podcasts_for_states(states)
def get_subscription_changes(self, device, since, now, domain): """ gets new, removed and current subscriptions """ # DB: get all podcast states for the device podcast_states = podcast_states_for_device(device.id) add, rem = subscription_changes(device.id, podcast_states, since, now) subscriptions = filter(lambda s: s.is_subscribed_on(device), podcast_states) # DB get podcast objects for the subscribed podcasts subscriptions = podcasts_for_states(subscriptions) podcasts = dict( (p.url, p) for p in subscriptions ) add = [podcast_data(podcasts.get(url), domain) for url in add ] return add, rem, subscriptions