コード例 #1
0
ファイル: podcastsutil.py プロジェクト: whenthelight/Peppy
    def get_podcast_info_from_disk(self, index, podcast):
        """ Get the info of loaded podcast as State object
        
        :param index: podcast index
        :param podcast: podcast dictionary
        
        :return: podcast info as State object
        """
        s = State()
        s.index = index
        s.name = podcast["name"]
        s.l_name = s.name
        s.url = podcast["url"]
        s.online = False
        s.description = podcast["summary"]
        s.fixed_height = int(self.podcast_button_font_size * 0.8)
        s.file_type = PODCASTS
        s.comparator_item = s.index
        s.bgr = self.config[COLORS][COLOR_DARK]
        s.show_bgr = True

        try:
            img = os.path.join(self.config[PODCASTS_FOLDER], podcast["image"])
        except:
            img = ''

        s.image_name = img
        s.icon_base = self.get_podcast_image(img, 0.5, 0.8,
                                             self.podcast_button_bb, False)
        self.summary_cache[s.url] = s

        return s
コード例 #2
0
    def get_podcast_info(self, index, podcast_url):
        """ Get podcast info as state object
        
        :param index: podcast index
        :param podcast_url: podcast url
        
        :return: podcast info as State object
        """
        try:
            response = requests.get(podcast_url)
            if response.status_code == 404:
                return None
            rss = feedparser.parse(response.content)
            if rss and getattr(rss, "bozo_exception", None):
                return None
        except:
            return None

        s = State()
        s.index = index
        s.name = rss.feed.title
        s.l_name = s.name
        s.description = rss.feed.subtitle
        s.url = podcast_url
        s.online = True
        s.fixed_height = int(self.podcast_button_font_size * 0.8)
        s.file_type = PODCASTS
        s.comparator_item = s.index
        s.bgr = self.config[COLORS][COLOR_DARK]
        s.show_bgr = True

        if 'image' in rss.feed and 'href' in rss.feed.image:
            img = rss.feed.image.href.strip()
        else:
            img = ''

        s.image_name = img
        s.icon_base = self.get_podcast_image(img, 0.48, 0.8,
                                             self.podcast_button_bb)
        self.summary_cache[s.url] = s

        return s