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')
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')
def format_track(track): en = et.Element('Entry') i = et.Element('Id') if 'id' not in track: log.critical('issue with playlist :%s' % track) i.text = track['id'] 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) return (en, track,)
def format_track(track): # log.error('format: %s' % track['id']) en = et.Element('Entry') i = et.Element('Id') if 'id' not in track: log.critical('issue with playlist :%s' % 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) return en
def got_result(res): uri = res['url'] return (uri, didl_encode(res))
def got_result(res): uri = res['url'] return (uri, didl_encode(res))