Exemplo n.º 1
0
        def generate_tracklist(tracks, tracklist=None):
#             log.err(tracks)
            if not isinstance(tracks, list):
                tracks = [tracks]
            tl = et.Element('TrackList')
            for idx, track in enumerate(tracks):
#                 log.err(track)
                if isinstance(track, dict):
                    track = mpd_decode(track)
                else:
#                     log.err(track)
                    nd = {}
                    for d in track:
#                         log.err(d)
                        nd.update(d)
                    track = mpd_decode(nd)
#                     log.msg(nd)
                en = et.Element('Entry')
                i = et.Element('Id')
                if not 'id' in track:
                    if tracklist:
                        track.update({'id': str(tracklist[idx])})
                    else:
                        log.err(track)
                i.text = track['id'].decode('utf-8')
                en.append(i)
                uri = et.Element('Uri')
                uri.text = track['url'].decode('utf-8')
                en.append(uri)
                md = et.Element('Metadata')
                md.text = didl_encode(track)
                en.append(md)
                tl.append(en)
            return et.tostring(tl)
Exemplo n.º 2
0
 def got_tracks(tracks):
     if not isinstance(tracks, list):
         tracks = [tracks]
     sl = []
     for track in tracks:
         t = mpd_decode(track)
         sl.append(self.get_sticker(t['url'], t))
     return defer.gatherResults(sl)
Exemplo n.º 3
0
 def getmd(md):
     if isinstance(md, list):
         nd = {}
         for d in md:
             nd.update(d)
         md = nd
     if md != self._metadata:
         self._metadata = md
         #                 log.error(unicode(md))
         self.metadata = mpd_decode(self._metadata)
         if self._track_duration != self.metadata['duration']:
             self._track_duration = self.metadata['duration']
             self.upnp_eventAV(self._track_duration,
                               'CurrentTrackDuration')
             sec = upnptime_to_mpdtime(self._track_duration)
             self.ohduration = sec
             self.oh_eventINFO(sec, 'duration')
             self.oh_eventTIME(sec, 'duration')
         if self.songid != self.metadata['id']:
             self.trackcount += 1
             self.detailscount = 0
             self.metatextcount = 0
             self.songid = self.metadata['id']
             self.upnp_eventAV(int(self.songid), 'CurrentTrack')
             self.oh_eventPLAYLIST(int(self.songid), 'id')
             self.oh_eventTIME(self.trackcount, 'trackcount')
             self.oh_eventINFO(self.trackcount, 'trackcount')
             if self.timer:
                 self.timer.set()
         if 'url' in self.metadata.keys():
             self._track_URI = self.metadata['url']
             self.upnp_eventAV(self._track_URI, 'AVTransportURI')
             self.oh_eventINFO(self._track_URI, 'uri')
             self.upnp_eventAV(self._track_URI, 'CurrentTrackURI')
             try:
                 self.oh_eventINFO(self.metadata['codec'].upper(),
                                   'codecname')
                 if self.metadata['codec'].lower() in ['flac', 'm4a']:
                     self.lossless = True
                     self.oh_eventINFO(1, 'lossless')
                 else:
                     self.lossless = False
                     self.oh_eventINFO(0, 'lossless')
                 self.codecname = self.metadata['codec'].upper()
             except KeyError:
                 pass
         self.metadata_str = didl_encode(self.metadata)
         self.oh_eventINFO(self.metadata_str, 'metadata')
         self.upnp_eventAV(self.metadata_str, 'AVTransportURIMetaData')
         if self.tracksmax == 0:
             self.tracksmax = 10000
             self.oh_eventPLAYLIST(self.tracksmax, 'tracksmax')
Exemplo n.º 4
0
        def getmd(md):
            if isinstance(md, list):
                nd = {}
                for d in md:
                    nd.update(d)
                md = nd
            if md != self._metadata:
                self._metadata = md
#                 log.error(unicode(md))
                self.metadata = mpd_decode(self._metadata)
                if self._track_duration != self.metadata['duration']:
                    self._track_duration = self.metadata['duration']
                    self.upnp_eventAV(self._track_duration,
                                      'CurrentTrackDuration')
                    sec = upnptime_to_mpdtime(self._track_duration)
                    self.ohduration = sec
                    self.oh_eventINFO(sec, 'duration')
                    self.oh_eventTIME(sec, 'duration')
                if self.songid != self.metadata['id']:
                    self.trackcount += 1
                    self.detailscount = 0
                    self.metatextcount = 0
                    self.songid = self.metadata['id']
                    self.upnp_eventAV(int(self.songid), 'CurrentTrack')
                    self.oh_eventPLAYLIST(int(self.songid), 'id')
                    self.oh_eventTIME(self.trackcount, 'trackcount')
                    self.oh_eventINFO(self.trackcount, 'trackcount')
                    if self.timer:
                        self.timer.set()
                if 'url' in self.metadata.keys():
                    self._track_URI = self.metadata['url']
                    self.upnp_eventAV(self._track_URI, 'AVTransportURI')
                    self.oh_eventINFO(self._track_URI, 'uri')
                    self.upnp_eventAV(self._track_URI, 'CurrentTrackURI')
                    try:
                        self.oh_eventINFO(
                            self.metadata['codec'].upper(), 'codecname')
                        if self.metadata['codec'].lower() in ['flac', 'm4a']:
                            self.lossless = True
                            self.oh_eventINFO(1, 'lossless')
                        else:
                            self.lossless = False
                            self.oh_eventINFO(0, 'lossless')
                        self.codecname = self.metadata['codec'].upper()
                    except KeyError:
                        pass
                self.metadata_str = didl_encode(self.metadata)
                self.oh_eventINFO(self.metadata_str, 'metadata')
                self.upnp_eventAV(self.metadata_str, 'AVTransportURIMetaData')
                if self.tracksmax == 0:
                    self.tracksmax = 10000
                    self.oh_eventPLAYLIST(self.tracksmax, 'tracksmax')