コード例 #1
0
 def __init__(self):
     '''
     Constructor
     '''
     MusicService.__init__(self, "Radio Service", "station")
     self.stations = {}
     id = 0
     for name, url in STATION_DICT.iteritems():
         # there is only one track per stations; the main url
         tracks = [Track(0, name)]
         self.stations[id] = Playlist(id, name, tracks)
         id += 1
コード例 #2
0
 def __init__(self):
     '''
     Constructor
     '''
     MusicService.__init__(self, "Radio Service", "station")
     self.stations = {}
     id = 0
     for name, url in STATION_DICT.iteritems():
         # there is only one track per stations; the main url
         tracks = [Track(0, name)]
         self.stations[id] = Playlist(id, name, tracks)
         id += 1
コード例 #3
0
 def __init__(self, path):
     '''
     Constructor
     :param: path Path to directory storing local music
         Local music is stored in the following format:
             [Top Level Path]
             |-- Playlist 0
                 |-- Song 0
                 |-- Song 1
             |-- Playlist 1
                 |-- Song 0
             etc...
     '''
     MusicService.__init__(self, "Local Service", "playlist")
     self.path = path
     self.playlists = {}
     # dictionary (acting like a multi-dimensional array) that stores 
     # locations of song files per playlist 
     # (i.e. streams[playlist_id,song_id])
     self.streams = {}
     pl_id = 0
     # sort playlist orderings
     for dir in sorted(os.listdir(self.path)):
         # directories indicate playlists
         pl_path = os.path.join(self.path, dir)
         if (os.path.isdir(pl_path)):
             track_id = 0
             tracks = []
             # skip if the directory is empty
             if not(os.listdir(pl_path)):
                 continue
             # iterate in sorted order
             for track in sorted(os.listdir(pl_path)):
                 # tracks are files in a directory
                 track_path = os.path.join(pl_path, track)
                 if ((os.path.isfile(track_path)) and 
                         (track_path.endswith(FILE_TYPES))):
                     tracks.append(Track(track_id, track))
                     stream_uri = "file://" + os.path.abspath(track_path)
                     self.streams[pl_id,track_id] = stream_uri 
                     track_id += 1
             # construct final playlist
             self.playlists[pl_id] = Playlist(pl_id, dir, tracks)
             pl_id += 1
コード例 #4
0
 def __init__(self, path):
     '''
     Constructor
     :param: path Path to directory storing local music
         Local music is stored in the following format:
             [Top Level Path]
             |-- Playlist 0
                 |-- Song 0
                 |-- Song 1
             |-- Playlist 1
                 |-- Song 0
             etc...
     '''
     MusicService.__init__(self, "Local Service", "playlist")
     self.path = path
     self.playlists = {}
     # dictionary (acting like a multi-dimensional array) that stores
     # locations of song files per playlist
     # (i.e. streams[playlist_id,song_id])
     self.streams = {}
     pl_id = 0
     # sort playlist orderings
     for dir in sorted(os.listdir(self.path)):
         # directories indicate playlists
         pl_path = os.path.join(self.path, dir)
         if (os.path.isdir(pl_path)):
             track_id = 0
             tracks = []
             # skip if the directory is empty
             if not (os.listdir(pl_path)):
                 continue
             # iterate in sorted order
             for track in sorted(os.listdir(pl_path)):
                 # tracks are files in a directory
                 track_path = os.path.join(pl_path, track)
                 if ((os.path.isfile(track_path))
                         and (track_path.endswith(FILE_TYPES))):
                     tracks.append(Track(track_id, track))
                     stream_uri = "file://" + os.path.abspath(track_path)
                     self.streams[pl_id, track_id] = stream_uri
                     track_id += 1
             # construct final playlist
             self.playlists[pl_id] = Playlist(pl_id, dir, tracks)
             pl_id += 1