コード例 #1
0
ファイル: MediaStore.py プロジェクト: dekoza/interference
    def get_item(self, parent_id = AUDIO_ALBUM_CONTAINER_ID):
        item = DIDLLite.MusicAlbum(self.id, parent_id, self.title)

        if __version_info__ >= (0,6,4):
            if self.get_child_count() > 0:
                res = DIDLLite.PlayContainerResource(self.store.server.uuid,cid=self.get_id(),fid=str(TRACK_COUNT+int(self.get_children()[0].get_id())))
                item.res.append(res)
        return item
コード例 #2
0
    def _update_data(self):
        '''get the feed xml, parse it, etc.'''
        feed_urls = []
        if self.opml_url:
            tree = ElementTree(file=urllib.request.urlopen(self.opml_url))
            body = tree.find('body')
            for outline in body.findall('outline'):
                feed_urls.append(outline.attrib['url'])

        if self.feed_urls:
            feed_urls = self.feed_urls.split()
        container_id = 100
        item_id = 1001
        for feed_url in feed_urls:
            netloc, path, query, fragment = urlsplit(feed_url)[1:]
            conn = http.client.HTTPConnection(netloc)
            conn.request('HEAD', f'{path}?{query}#{fragment}')
            res = conn.getresponse()
            if res.status >= 400:
                self.warning(
                    f'error getting {feed_url} status code: {res.status:d}')
                continue
            fp_dict = feedparser.parse(feed_url)
            name = fp_dict.feed.title
            self.store[container_id] = FeedContainer(ROOT_CONTAINER_ID,
                                                     container_id, name)
            self.store[ROOT_CONTAINER_ID].children.append(
                self.store[container_id])
            self.store[VIDEO_FOLDER_CONTAINER_ID].children.append(
                self.store[container_id])
            self.store[AUDIO_ALBUM_CONTAINER_ID].children.append(
                self.store[container_id])
            for item in fp_dict.entries:
                for enclosure in item.enclosures:
                    self.store[item_id] = FeedEnclosure(
                        self,
                        container_id,
                        item_id,
                        f'{item_id:04d} - {item.title}',
                        enclosure,
                    )
                    self.store[container_id].children.append(
                        self.store[item_id])
                    if enclosure.type.startswith('audio'):
                        self.store[AUDIO_ALL_CONTAINER_ID].children.append(
                            self.store[item_id])
                        if not isinstance(self.store[container_id].item,
                                          DIDLLite.MusicAlbum):
                            self.store[
                                container_id].item = DIDLLite.MusicAlbum(
                                    container_id, AUDIO_ALBUM_CONTAINER_ID,
                                    name)

                    item_id += 1
            if container_id <= 1000:
                container_id += 1
            else:
                raise Exception('to many containers')
コード例 #3
0
ファイル: mediadb_storage.py プロジェクト: Python3pkg/Cohen
    def get_item(self):
        item = DIDLLite.MusicAlbum(self.storeID + 1000, AUDIO_ALBUM_CONTAINER_ID, self.title)
        item.artist = self.artist.name
        item.childCount = self.get_child_count()
        if len(self.cover) > 0:
            _, ext = os.path.splitext(self.cover)
            item.albumArtURI = ''.join((self.store.urlbase, str(self.get_id()), '?cover', ext))

        if self.get_child_count() > 0:
            res = DIDLLite.PlayContainerResource(self.store.server.uuid, cid=self.get_id(), fid=self.get_children()[0].get_id())
            item.res.append(res)
        return item
コード例 #4
0
ファイル: ampache_storage.py プロジェクト: Python3pkg/Cohen
    def get_item(self, parent_id=AUDIO_ALBUM_CONTAINER_ID):
        item = DIDLLite.MusicAlbum(self.id, parent_id, self.title)
        item.childCount = self.get_child_count()
        item.artist = self.artist
        item.albumArtURI = self.cover
        #if item.childCount > 0:
        #    d = defer.maybeDeferred(self.get_children, 0, 1)

        #    def process_result(r,item):
        #        res = DIDLLite.PlayContainerResource(self.store.server.uuid,cid=self.get_id(),fid=r[0].get_id())
        #        item.res.append(res)
        #        return item

        #    def got_error(f,item):
        #        return item

        #    d.addCallback(process_result,item)
        #    d.addErrback(got_error,item)
        #    return d
        return item
コード例 #5
0
 def get_item(self):
     if self.item is None:
         self.item = DIDLLite.MusicAlbum(id=self.get_id(),
                                         parentID=self.parent.get_id(),
                                         title=self.name,
                                         restricted=True)
         self._set_item_defaults(searchClass="object.item.audioItem")
         self.item.artist = self.artist
         self.item.creator = self.artist
         if self.id:
             res = self._db.getAlbumCoverArtId(self.id)
             if res and not res.error():
                 data = res.data()
                 for d in data:
                     for coverid in d.itervalues():
                         if int(coverid) != 0:
                             self.item.albumArtURI = self.store.getCoverArtUri(
                                 coverid)
                             #								Log.d("%s - %s: %s" %(self.artist, self.name, self.item.albumArtURI))
                             break
     return self.item
コード例 #6
0
    def get_item(self):
        item = DIDLLite.MusicAlbum(self.get_id(), AUDIO_ALBUM_CONTAINER_ID, self.title)
        item.artist = self.artist.name
        item.childCount = self.get_child_count()
        if self.cover:
            _,ext =  os.path.splitext(self.cover)
            item.albumArtURI = ''.join((self._db.urlbase,
                                        self.get_id(), '?cover', ext))

        def got_tracks(tracks):
            res = DIDLLite.PlayContainerResource(self._db.server.uuid,
                                                 cid=self.get_id(),
                                                 fid=tracks[0].get_id())
            item.res.append(res)
            return item

        if item.childCount > 0:
            dfr = self.get_children(request_count=1)
            dfr.addCallback(got_tracks)
        else:
            dfr = defer.succeed(item)
        return dfr
コード例 #7
0
 def get_item(self, parent_id=AUDIO_ALBUM_CONTAINER_ID):
     item = DIDLLite.MusicAlbum(self.id, parent_id, self.name)
     item.childCount = self.get_child_count()
     item.artist = self.artist
     item.albumArtURI = self.cover
     return item