<s> """<STR_LIT>""" <EOL> from audioaddict import AudioAddict <EOL> AA = AudioAddict ( ) <EOL> MUSIC_PREFIX = '<STR_LIT>' <EOL> NAME = '<STR_LIT>' <EOL> ART = '<STR_LIT>' <EOL> ICON = '<STR_LIT>' <EOL> def Start ( ) : <EOL> """<STR_LIT>""" <EOL> ObjectContainer . title1 = NAME <EOL> DirectoryObject . thumb = R ( ICON ) <EOL> HTTP . CacheTime = CACHE_1HOUR <EOL> def ValidatePrefs ( ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> @ handler ( MUSIC_PREFIX , NAME , art = ART , thumb = ICON ) <EOL> def MusicMainMenu ( ) : <EOL> """<STR_LIT>""" <EOL> oc = ObjectContainer ( ) <EOL> services = AA . get_validservices ( ) <EOL> for serv in sorted ( services , key = services . get ) : <EOL> oc . add ( DirectoryObject ( <EOL> key = Callback ( GetChannels , serv = serv ) , <EOL> title = services [ serv ] <EOL> ) ) <EOL> return oc <EOL> @ route ( MUSIC_PREFIX + '<STR_LIT>' ) <EOL> def GetChannels ( serv ) : <EOL> """<STR_LIT>""" <EOL> AA . set_service ( serv ) <EOL> AA . set_listenkey ( Prefs [ '<STR_LIT>' ] ) <EOL> AA . set_streampref ( Prefs [ '<STR_LIT>' + serv ] ) <EOL> AA . set_sourcepref ( Prefs [ '<STR_LIT>' ] ) <EOL> oc = ObjectContainer ( title1 = AA . get_servicename ( serv ) ) <EOL> fmt = AA . get_streamdetails ( ) [ '<STR_LIT>' ] <EOL> bitrate = AA . get_streamdetails ( ) [ '<STR_LIT>' ] <EOL> for channel in AA . get_batchinfo ( refresh = True ) : <EOL> if ( not channel [ '<STR_LIT:key>' ] in Dict ) or ( Prefs [ '<STR_LIT>' ] == True ) : <EOL> Dict [ channel [ '<STR_LIT:key>' ] ] = AA . get_streamurl ( channel [ '<STR_LIT:key>' ] ) <EOL> if Prefs [ '<STR_LIT>' ] : <EOL> Log . Debug ( '<STR_LIT>' % Dict [ channel [ '<STR_LIT:key>' ] ] ) <EOL> oc . add ( CreateChannelObject ( <EOL> url = Dict [ channel [ '<STR_LIT:key>' ] ] , <EOL> title = channel [ '<STR_LIT:name>' ] , <EOL> summary = channel [ '<STR_LIT:description>' ] , <EOL> fmt = fmt , <EOL> bitrate = bitrate , <EOL> thumb = '<STR_LIT>' + channel [ '<STR_LIT>' ] <EOL> ) ) <EOL> oc . objects . sort ( key = lambda obj : obj . title ) <EOL> return oc <EOL> @ route ( MUSIC_PREFIX + '<STR_LIT>' ) <EOL> def CreateChannelObject ( <EOL> url , <EOL> title , <EOL> summary , <EOL> fmt , <EOL> bitrate , <EOL> thumb , <EOL> include_container = False <EOL> ) : <EOL> """<STR_LIT>""" <EOL> if fmt == '<STR_LIT>' : <EOL> container = Container . MP3 <EOL> audio_codec = AudioCodec . MP3 <EOL> elif fmt == '<STR_LIT>' : <EOL> container = Container . MP4 <EOL> audio_codec = AudioCodec . AAC <EOL> debug_summary = [ ] <EOL> debug_summary . append ( summary ) <EOL> if Prefs [ '<STR_LIT>' ] : <EOL> debug_summary . append ( '<STR_LIT>' % ( fmt , bitrate ) ) <EOL> debug_summary . append ( '<STR_LIT>' % url ) <EOL> track_object = TrackObject ( <EOL> key = Callback ( CreateChannelObject , <EOL> url = url , <EOL> title = title , <EOL> summary = '<STR_LIT:U+0020>' . join ( debug_summary ) , <EOL> fmt = fmt , <EOL> bitrate = bitrate , <EOL> thumb = thumb , <EOL> include_container = True <EOL> ) , <EOL> rating_key = url , <EOL> title = title , <EOL> summary = '<STR_LIT:U+0020>' . join ( debug_summary ) , <EOL> thumb = thumb , <EOL> items = [ <EOL> MediaObject ( <EOL> parts = [ <EOL> PartObject ( key = url ) <EOL> ] , <EOL> container = container , <EOL> audio_codec = audio_codec , <EOL> bitrate = bitrate , <EOL> audio_channels = <NUM_LIT:2> , <EOL> optimized_for_streaming = True <EOL> ) <EOL> ] <EOL> ) <EOL> if include_container : <EOL> return ObjectContainer ( objects = [ track_object ] ) <EOL> else : <EOL> return track_object </s>
