def subscribe(self):
     """
     Subscribe to a podcast. Then download the first x number of episodes as defined in the settings.
     """
     message = ""
     data = self._open_data_source()
     if data is None or not data:
         exit("Not a valid XML file or URL feed!")
     podcasts = self._iterate_feed(data)
     if podcasts:
         message += self._save_podcasts(podcasts)
         message += self._delete_old_podcasts(podcasts[0]['dir'])
     if self.db.has_mail_users():
         mail_updates(message, self.db.get_mail_users())
     print message
 def subscribe(self):
     """
     Subscribe to a podcast. Then download the first x number of episodes as defined in the settings.
     """
     message = ""
     data = self._open_data_source()
     if data is None or not data:
         exit("Not a valid XML file or URL feed!")
     podcasts = self._iterate_feed(data)
     if podcasts:
         message += self._save_podcasts(podcasts)
         message += self._delete_old_podcasts(podcasts[0]['dir'])
     if self.db.has_mail_users():
         mail_updates(message, self.db.get_mail_users())
     print message
 def update(self):
     """
     Update and loop through all subscriptions.
     Then download the first x number of episodes as defined in the settings.
     """
     message = ""
     for sub in self.db.get_subscriptions():
         channel_name = sub[0]
         self.feed = sub[1]
         data = self._open_data_source()
         if data:
             message += "Feed for subscription: '" + channel_name + "' is updating...\n"
             podcasts = self._iterate_feed(data)
             if podcasts:
                 message += self._save_podcasts(podcasts)
                 message += self._delete_old_podcasts(podcasts[0]['dir'])
             else:
                 message += "No podcasts to update.\n"
     if self.db.has_mail_users():
         mail_updates(message, self.db.get_mail_users())
     print message
 def update(self):
     """
     Update and loop through all subscriptions.
     Then download the first x number of episodes as defined in the settings.
     """
     message = ""
     for sub in self.db.get_subscriptions():
         channel_name = sub[0]
         self.feed = sub[1]
         data = self._open_data_source()
         if data:
             message += "Feed for subscription: '" + channel_name + "' is updating...\n"
             podcasts = self._iterate_feed(data)
             if podcasts:
                 message += self._save_podcasts(podcasts)
                 message += self._delete_old_podcasts(podcasts[0]['dir'])
             else:
                 message += "No podcasts to update.\n"
     if self.db.has_mail_users():
         mail_updates(message, self.db.get_mail_users())
     print message