Exemple #1
0
 def search(self, args, path):        
     if args.identifier == '':
         query = self.ui_helper.keyboardText()
     else:
         query = args.identifier
     if query is not None and query is not '':
         tracks_model = Model.from_object(self.server.search(Page(args.start, args.offset, args.max_items, query)))
         self.ui_helper.create_list_of_tracks(Model.from_object_list(tracks_model.tracks), Page.from_obj(tracks_model.page), path)
     self.ui_helper.end_directory()
Exemple #2
0
    def add_context_menu(self, track, play_url, li):
        browse_album_url = Router.url_for(Paths.ALBUM_TRACKS,
                                          Model(album=track.album_uri))
        browse_artist_url = Router.url_for(Paths.ARTIST_ALBUMS_FOR_TRACK,
                                           Model(track=track.uri))

        li.addContextMenuItems([
            (self.add_on.getLocalizedString(30032),
             UiHelper.RUN_PLUGIN_SCRIPT % play_url),
            (self.add_on.getLocalizedString(30031),
             UiHelper.UPDATE_CONTAINER_SCRIPT % browse_album_url),
            (self.add_on.getLocalizedString(30030),
             UiHelper.UPDATE_CONTAINER_SCRIPT % browse_artist_url)
        ])
 def search(self, page = {}):
     page = Page.from_obj(page)
     session = self.current_session()
     search_result = Search(page, session).run_and_wait()
     tracks = LoadTrack.from_list(search_result.tracks(), session)
     
     return Model(tracks = self.model_factory.to_track_list_model(tracks, session), page = page)
Exemple #4
0
    def create_list_of_albums(self, albums):
        xbmcplugin.setContent(self.addon_handle, UiHelper.CONTENT_ALBUMS)

        for album in albums:
            url = Router.url_for(Paths.ALBUM_TRACKS, Model(album=album.uri))
            self.create_folder_item('%s [%s]' % (album.name, album.year), url,
                                    album.image)
Exemple #5
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))
Exemple #6
0
    def to_album_model(self, album):

        return Model(name=album.name(),
                     year=album.year(),
                     image=self.url_gen.get_image_url(
                         album.cover(image.ImageSize.Large)),
                     uri=self.url_gen.get_album_uri(album))
 def tracks_model(self, playlist, page, session):
     if not page.is_infinite():
         tracks_model = self.partial_result(playlist, page, session)
     else:            
         tracks = LoadTrack.from_list(playlist.tracks(), session)
         tracks_model = Model(tracks = self.model_factory.to_track_list_model(tracks, session), page = Page())
      
     return tracks_model
Exemple #8
0
 def inbox(self, args):
     inbox = Model.from_object(self.server.inbox())
     label_tpl = '%s (%d)'
     self.create_inbox_menu(label_tpl, self.add_on.getLocalizedString(30035), Paths.INBOX_PLAYLISTS, count = len(inbox.playlists))
     self.create_inbox_menu(label_tpl, self.add_on.getLocalizedString(30036), Paths.INBOX_ARTISTS, count = len(inbox.artists))
     self.create_inbox_menu(label_tpl, self.add_on.getLocalizedString(30037), Paths.INBOX_ALBUMS, count = len(inbox.albums))
     self.create_inbox_menu(label_tpl, self.add_on.getLocalizedString(30038), Paths.INBOX_TRACKS, count = len(inbox.tracks))
     self.ui_helper.end_directory()
Exemple #9
0
 def get_playlist_url(self, playlist):
     if playlist.is_folder:
         return Router.url_for(Paths.FOLDER_PLAYLISTS,
                               Model(folder_id=playlist.folder_id))
     else:
         return Router.url_for(
             Paths.GET_PLAYLIST,
             self.settings.initial_page_for_pagination(playlist.uri))
 def partial_result(self, playlist, page, session):
     tracks = []
     page = Page(page.start, page.offset, playlist.num_tracks(), page.identifier)
     
     for i in page.current_range():
         track = playlist.track(i)
         tracks.append(track)
         
     return Model(tracks = self.model_factory.to_track_list_model(tracks, session), page = page)
Exemple #11
0
    def artist_albums(self, args):
        albums = Model.from_object_list(self.server.artist_albums(args.artist))
        self.ui_helper.create_list_of_albums(albums)
        self.ui_helper.end_directory()

            
      
    
        
        
        
Exemple #12
0
    def to_playlist_model(self,
                          playlist,
                          index,
                          folder_name=None,
                          folder_id=0):

        return Model(name=self.playlist_name(playlist, folder_name),
                     owner=playlist.owner().display_name(),
                     index=index,
                     uri=self.playlist_uri(playlist),
                     is_folder=folder_name is not None,
                     folder_id=str(folder_id))
Exemple #13
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)
Exemple #14
0
    def execute(self):
        function = self.route_config.get(self.path)
        args_str = self.args.get('args')
        args = {}
        if args_str != None:
            args = json.loads(args_str)
        if function == None:
            raise Exception(
                "Incorrect router config. No function provided for path = " +
                self.path)

        if self.context != None:
            self.execute_path_function(function, Model.from_object(args),
                                       self.path)
        else:
            function(args)
Exemple #15
0
    def create_list_of_artists(self, artists):
        xbmcplugin.setContent(self.addon_handle, UiHelper.CONTENT_ARTISTS)

        for artist in artists:
            url = Router.url_for(Paths.ARTIST_ALBUMS, Model(artist=artist.uri))
            self.create_folder_item('%s' % (artist.name), url)
Exemple #16
0
 def inbox_tracks(self, args):
     inbox = Model.from_object(self.server.inbox())
     self.ui_helper.create_list_of_tracks(Model.from_object_list(inbox.tracks))
     self.ui_helper.end_directory()
Exemple #17
0
 def inbox_playlists(self, args):
     inbox = Model.from_object(self.server.inbox())
     self.ui_helper.create_list_of_playlists(Model.from_object_list(inbox.playlists), show_owner = True)
     self.ui_helper.end_directory()
Exemple #18
0
    def to_artist_model(self, artist):

        return Model(name=artist.name(),
                     uri=link.create_from_artist(artist).as_string())
Exemple #19
0
 def album_tracks(self, args):
     tracks = Model.from_object_list(self.server.album_tracks(args.album))
     self.ui_helper.create_list_of_tracks(tracks)
     self.ui_helper.end_directory()
Exemple #20
0
 def play_lists_menu(self, args):
     playlists = Model.from_object_list(self.server.playlists())
     self.ui_helper.create_list_of_playlists(playlists)
     self.ui_helper.end_directory()
Exemple #21
0
 def get_playlist(self, args, path):
     tracks_model = Model.from_object(self.server.playlist_tracks(args))
     self.ui_helper.create_list_of_tracks(Model.from_object_list(tracks_model.tracks), Page.from_obj(tracks_model.page), path)        
     self.ui_helper.end_directory()
Exemple #22
0
 def folder_playlists(self, args):
     playlists = Model.from_object_list(self.server.folder_playlists(args.folder_id))
     self.ui_helper.create_list_of_playlists(playlists)
     self.ui_helper.end_directory()