Ejemplo n.º 1
0
 def to_track_model(self, track, session):
     
     track_artist_names = [artist.name() for artist in track.artists()]
     return Model(track=self.get_track_name(track, session),
                  album=self.get_album_name(track),                     
                  artist=", ".join(track_artist_names),
                  uri=link.create_from_track(track).as_string(),
                  type=link.create_from_track(track).type(),
                  album_uri=self.url_gen.get_album_uri(track.album()),
                  iconImage=self.url_gen.get_icon_url(track),
                  thumbnailImage=self.url_gen.get_thumbnail_url(track),
                  path=self.get_track_path(track, session),
                  time=track.duration() / 1000)
Ejemplo n.º 2
0
    def to_track_model(self, track, session):

        track_artist_names = [artist.name() for artist in track.artists()]
        return Model(track=self.get_track_name(track, session),
                     album=self.get_album_name(track),
                     artist=", ".join(track_artist_names),
                     uri=link.create_from_track(track).as_string(),
                     type=link.create_from_track(track).type(),
                     album_uri=self.url_gen.get_album_uri(track.album()),
                     iconImage=self.url_gen.get_icon_url(track),
                     thumbnailImage=self.url_gen.get_thumbnail_url(track),
                     path=self.get_track_path(track, session),
                     time=track.duration() / 1000)
Ejemplo n.º 3
0
    def to_inbox_model(self, items, session):
        track_links = [link.create_from_track(track) for track in items]

        albums = [
            track_link.as_album() for track_link in track_links
            if track_link.type() is LinkType.Album
        ]
        artists = [
            track_link.as_artist() for track_link in track_links
            if track_link.type() is LinkType.Artist
        ]
        tracks = [
            track_link.as_track() for track_link in track_links
            if track_link.type() is LinkType.Track
        ]
        playlists = [
            Playlist(playlist.create(session, track_link))
            for track_link in track_links
            if track_link.type() is LinkType.Playlist
        ]

        return Model(albums=self.to_album_list_model(albums),
                     artists=self.to_artist_list_model(artists),
                     tracks=self.to_track_list_model(tracks, session),
                     playlists=self.to_playlist_list_model(playlists))
Ejemplo n.º 4
0
    def get_track_path(self, track, session):
        path = "http://127.0.0.1/spotlight/empty-track/"
        if not track.get_availability(session) is TrackAvailability.Available:
            # Use unique nonexistent URL for nonavailable tracks. Otherwise
            # XBMC treats all nonavailable tracks as one.
            path += link.create_from_track(track).as_string()
        else:
            path = self.url_gen.get_track_url(track)

        return path
Ejemplo n.º 5
0
 def get_track_path(self, track, session):
     path = "http://127.0.0.1/spotlight/empty-track/"
     if not track.get_availability(session) is TrackAvailability.Available:
         # Use unique nonexistent URL for nonavailable tracks. Otherwise
         # XBMC treats all nonavailable tracks as one.
         path += link.create_from_track(track).as_string()
     else:
         path=self.url_gen.get_track_url(track)
     
     return path
Ejemplo n.º 6
0
 def to_inbox_model(self, items, session):
     track_links = [link.create_from_track(track) for track in items]
                        
     albums = [track_link.as_album() 
               for track_link in track_links if track_link.type() is LinkType.Album]
     artists = [track_link.as_artist() 
                for track_link in track_links if track_link.type() is LinkType.Artist]
     tracks = [track_link.as_track() 
               for track_link in track_links if track_link.type() is LinkType.Track]
     playlists = [Playlist(playlist.create(session, track_link)) 
                  for track_link in track_links if track_link.type() is LinkType.Playlist]
     
     return Model(albums = self.to_album_list_model(albums),
                  artists = self.to_artist_list_model(artists),
                  tracks = self.to_track_list_model(tracks, session),
                  playlists = self.to_playlist_list_model(playlists))
Ejemplo n.º 7
0
 def _get_track_id(self, track):
     track_link = link.create_from_track(track)
     return track_link.as_string()[14:]
Ejemplo n.º 8
0
 def _get_track_id(self, track):
     track_link = link.create_from_track(track)
     return track_link.as_string()[14:]
Ejemplo n.º 9
0
    def get_track_id(self, track):

        return link.create_from_track(track).as_string()[14:]
Ejemplo n.º 10
0
    def get_track_id(self, track):

        return link.create_from_track(track).as_string()[14:]