Exemplo n.º 1
0
 def __update_for_url(self, url):
     """
         Update charts for url
         @param url as str
     """
     if not get_network_available():
         return
     debug("ItunesCharts::__update_for_url(): %s => %s" %
           (url, self.__LIMIT))
     web = Web()
     ids = self.__get_ids(url)
     position = len(ids)
     while ids:
         sleep(10)
         (itunes_id, itunes_genre) = ids.pop(0)
         album = self.__get_album(itunes_id)
         if self.__stop:
             return
         if album is None or not album.subitems:
             position -= 1
             continue
         album.mtime = self.__time + position
         for item in album.subitems:
             item.mtime = self.__time
         debug("ItunesCharts::__update_for_url(): %s - %s" %
               (album.name, album.artists))
         t = TagReader()
         with SqlCursor(Lp().db) as sql:
             genre_ids = t.add_genres(itunes_genre)
             sql.commit()
         genre_ids.append(Type.ITUNES)
         web.save_album_thread(album, DbPersistent.CHARTS, genre_ids)
         position -= 1
Exemplo n.º 2
0
 def __update_for_url(self, url):
     """
         Update charts for url
         @param url as str
     """
     if not get_network_available():
             return
     debug("SpotifyCharts::__update_for_url(): %s => %s" % (url,
                                                            self.__count))
     ids = self.__get_ids(url)
     web = Web()
     search = SpotifySearch()
     while ids:
         sleep(10)
         track_id = ids.pop(0)
         album_id = search.get_album_id(track_id)
         album = search.get_album(album_id)
         if album is None or album.exists_in_db():
             continue
         if self._stop:
             return
         Lp().db.del_tracks(Lp().tracks.get_old_from_charts(self.__count))
         debug("SpotifyCharts::__update_for_url(): %s - %s - %s" % (
                                                             album.name,
                                                             album.artists,
                                                             album_id))
         web.save_album(album, DbPersistent.CHARTS)
Exemplo n.º 3
0
 def __update_for_url(self, url):
     """
         Update charts for url
         @param url as str
     """
     if not get_network_available():
         return
     debug("SpotifyCharts::__update_for_url(): %s => %s" %
           (url, self.__count))
     ids = self.__get_ids(url)
     web = Web()
     search = SpotifySearch()
     while ids:
         sleep(10)
         track_id = ids.pop(0)
         album_id = search.get_album_id(track_id)
         album = search.get_album(album_id)
         if album is None or album.exists_in_db():
             continue
         if self._stop:
             return
         Lp().db.del_tracks(Lp().tracks.get_old_from_charts(self.__count))
         debug("SpotifyCharts::__update_for_url(): %s - %s - %s" %
               (album.name, album.artists, album_id))
         web.save_album(album, DbPersistent.CHARTS)
Exemplo n.º 4
0
 def __update_for_url(self, url):
     """
         Update charts for url
         @param url as str
     """
     if not get_network_available():
             return
     debug("ItunesCharts::__update_for_url(): %s => %s" % (url,
                                                           self.__LIMIT))
     web = Web()
     ids = self.__get_ids(url)
     position = len(ids)
     while ids:
         sleep(10)
         (itunes_id, itunes_genre) = ids.pop(0)
         album = self.__get_album(itunes_id)
         if self.__stop:
             return
         if album is None or not album.subitems:
             position -= 1
             continue
         album.mtime = self.__time + position
         for item in album.subitems:
             item.mtime = self.__time
         debug("ItunesCharts::__update_for_url(): %s - %s" % (
                                                             album.name,
                                                             album.artists))
         t = TagReader()
         with SqlCursor(Lp().db) as sql:
             genre_ids = t.add_genres(itunes_genre)
             sql.commit()
         genre_ids.append(Type.ITUNES)
         web.save_album_thread(album, DbPersistent.CHARTS, genre_ids)
         position -= 1
Exemplo n.º 5
0
 def __update_for_url(self, url):
     """
         Update charts for url
         @param url as str
     """
     if not get_network_available():
             return
     debug("SpotifyCharts::__update_for_url(): %s" % (url))
     ids = self.__get_ids(url)
     web = Web()
     search = SpotifySearch()
     position = len(ids)
     while ids:
         sleep(10)
         track_id = ids.pop(0)
         album = search.get_track(track_id)
         if self.__stop:
             return
         if album is None or not album.subitems:
             position -= 1
             continue
         for item in album.subitems:
             item.mtime = self.__time + position
         debug("SpotifyCharts::__update_for_url(): %s - %s - %s" % (
                                                             album.name,
                                                             album.artists,
                                                             track_id))
         web.save_album_thread(album, DbPersistent.CHARTS, [Type.SPOTIFY])
         position -= 1
Exemplo n.º 6
0
 def __update_for_url(self, url):
     """
         Update charts for url
         @param url as str
     """
     if not get_network_available():
             return
     debug("SpotifyCharts::__update_for_url(): %s" % (url))
     ids = self.__get_ids(url)
     web = Web()
     search = SpotifySearch()
     position = len(ids)
     while ids:
         sleep(10)
         track_id = ids.pop(0)
         album = search.get_track(track_id)
         if self.__stop:
             return
         if album is None or not album.subitems:
             position -= 1
             continue
         for item in album.subitems:
             item.mtime = self.__time + position
         debug("SpotifyCharts::__update_for_url(): %s - %s - %s" % (
                                                             album.name,
                                                             album.artists,
                                                             track_id))
         web.save_album_thread(album, DbPersistent.CHARTS, [Type.SPOTIFY])
         position -= 1
Exemplo n.º 7
0
 def __on_item_found(self, search, position):
     """
         Get track from search
         @param search as NetworkSearch
         @param position as int
     """
     if search.items:
         item = search.items[0]
         if item.is_track:
             debug("LastfmCharts::__on_item_found(): %s - %s" %
                   (item.name, item.artists))
             search.stop()
             search.disconnect_by_func(self.__on_item_found)
             item.mtime = self.__time + position
             web = Web()
             web.save_track(item, DbPersistent.CHARTS, [Type.LASTFM])
Exemplo n.º 8
0
 def __on_item_found(self, search, position):
     """
         Get track from search
         @param search as NetworkSearch
         @param position as int
     """
     if search.items:
         item = search.items[0]
         if item.is_track:
             debug("LastfmCharts::__on_item_found(): %s - %s" % (
                                                             item.name,
                                                             item.artists))
             search.stop()
             search.disconnect_by_func(self.__on_item_found)
             item.mtime = self.__time + position
             web = Web()
             web.save_track(item, DbPersistent.CHARTS, [Type.LASTFM])
Exemplo n.º 9
0
 def on_activated(self, persistent):
     """
         Download item
         @param persistent as DbPersistent
     """
     from lollypop.web import Web
     web = Web()
     web.connect("saved", self.__on_saved, persistent)
     if self.__item.is_track:
         web.save_track(self.__item, persistent)
     else:
         web.save_album(self.__item, persistent)
         if self.__progress is not None:
             self.__progress.set_opacity(1)
         web.connect("progress", self.__on_progress)
     self.__stack.set_visible_child_name("spinner")
     self.__stack.get_visible_child().start()
Exemplo n.º 10
0
 def on_activated(self, persistent):
     """
         Download item
         @param persistent as DbPersistent
     """
     from lollypop.web import Web
     web = Web()
     web.connect("saved", self.__on_saved, persistent)
     if self.__item.is_track:
         web.save_track(self.__item, persistent)
     else:
         web.save_album(self.__item, persistent)
         if self.__progress is not None:
             self.__progress.set_opacity(1)
         web.connect("progress", self.__on_progress)
     self.__stack.set_visible_child_name("spinner")
     self.__stack.get_visible_child().start()
Exemplo n.º 11
0
 def play(self):
     """
         Play row
     """
     from lollypop.web import Web
     Lp().player.emit('loading-changed', True)
     web = Web()
     if self.__item.is_track:
         web.save_track(self.__item, DbPersistent.NONE)
     else:
         web.save_album(self.__item, DbPersistent.NONE)
Exemplo n.º 12
0
 def _on_save_clicked(self, button):
     """
         Save into collection
         @param button as Gtk.Button
     """
     from lollypop.web import Web
     web = Web()
     if self.__item.is_track:
         web.save_track(self.__item, DbPersistent.EXTERNAL)
     else:
         web.save_album(self.__item, DbPersistent.EXTERNAL)
     self.destroy()