def __init__(self): super(MusicPlaylist, self).__init__() self.listen_db_file = get_cache_file("baidumusic/local_listen.db") self.status_db_file = get_cache_file("baidumusic/status.db") # Init default items self.default_list_item = MusicListItem("试听列表", list_type=MusicListItem.DEFAULT_TYPE) self.collect_list_item = MusicListItem("我的收藏", list_type=MusicListItem.COLLECT_TYPE, has_separator=True) # Init category list. self.category_list = CategoryView(enable_drag_drop=False, enable_multiple_select=True) self.category_list.add_items([self.default_list_item, self.collect_list_item]) del self.category_list.keymap["Delete"] self.category_list.draw_mask = self.draw_category_list_mask self.category_list.set_size_request(CATEGROYLIST_WIDTH, -1) self.category_list.connect("single-click-item", self.on_category_single_click) self.category_list.connect("right-press-items", self.on_category_right_press) self.category_list.set_highlight_item(self.default_list_item) # View box self.view_box = gtk.VBox() self.view_box.connect("size-allocate", self.on_viewbox_size_allocate) self.view_box.add(self.default_list_item.list_widget) # bottom_box = gtk.HBox(spacing=45) # bottom_box_align = gtk.Alignment() # bottom_box_align.set(0.5, 0.5, 1, 1) # bottom_box_align.set_padding(2, 2, 28, 0) # bottom_box_align.set_size_request(-1, 22) # bottom_box_align.add(bottom_box) # bottom_box_align.connect("expose_event", self.on_bottombox_expose_event) # self.search_button = create_toggle_button("toolbar/search", parent=bottom_box) # self.person_button = create_button("combo/artist", parent=bottom_box, no_hover=True) main_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True) main_paned.pack1(self.category_list, True, True) main_paned.pack2(self.view_box, True, False) # events event_manager.connect("login-success", self.on_event_login_success) event_manager.connect("collect-songs", self.on_event_collect_songs) event_manager.connect("add-songs", self.on_event_add_songs) event_manager.connect("play-songs", self.on_event_play_songs) event_manager.connect("save-listen-lists", self.on_event_save_listen_lists) event_manager.connect("save-playlist-status", self.save_status) # load playlists. self.online_thread_id = 0 self.new_list_thread_id = 0 self.load() self.load_online_lists() self.load_status() self.add(main_paned)
def __init__(self): super(MusicPlaylist, self).__init__() # Set db file self.listen_db_file = get_cache_file("neteasecloudmusic/local_listen.db") self.status_db_file = get_cache_file("neteasecloudmusic/status.db") # Set default & collect list item self.playing_list_item = MusicListItem("播放列表", MusicListItem.PLAYING_LIST_TYPE) # Set category list and connect click/right click self.category_list = CategoryView(enable_drag_drop=False, enable_multiple_select=True) self.category_list.add_items([self.playing_list_item]) del self.category_list.keymap["Delete"] self.category_list.draw_mask = self.draw_category_list_mask self.category_list.set_size_request(CATEGROYLIST_WIDTH, -1) self.category_list.connect("single-click-item", self.on_category_single_click) self.category_list.connect("right-press-items", self.on_category_right_press) #self.category_list.set_highlight_item(self.playing_list_item) # Set view_box self.view_box = gtk.VBox() self.view_box.connect("size-allocate", self.on_viewbox_size_allocate) #self.view_box.add(self.playing_list_item.list_widget) main_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True) main_paned.pack1(self.category_list, True, True) main_paned.pack2(self.view_box, True, False) """ Set events""" event_manager.connect("login-success", self.load_online_lists) event_manager.connect("relogin", self.relogin) event_manager.connect("add-songs-to-playing-list-and-play", self.add_songs_to_playing_list_and_play) event_manager.connect("add-songs-to-playing-list", self.add_songs_to_playing_list) event_manager.connect("save-playing-list-status", self.save) # Load playlists self.online_thread_id = 0 self.new_list_thread_id = 0 if nplayer.is_login: self.load_online_lists('') else: self.login_item = MusicListItem("登录", MusicListItem.LOGIN_LIST_TYPE) self.category_list.add_items([self.login_item]) self.load() self.add(main_paned)
def get_combo_all_cover(self, key="album"): cover_cache_dir = get_cache_dir("cover") if not os.path.isdir(cover_cache_dir): return None if len(MediaDB.get_all_uris()) < 4: return None if key == "album": if self.album_all_cover != None: return self.album_all_cover cache_files = [f for f in os.listdir(cover_cache_dir) if "-" in f] elif key == "artist": if self.artist_all_cover != None: return self.artist_all_cover cache_files = [f for f in os.listdir(cover_cache_dir) if "-" not in f] else: return None if len(cache_files) < 4: return None random.shuffle(cache_files) combo_image = composite_images([os.path.join(cover_cache_dir, f) for f in cache_files[:4]], 84, 84, get_cache_file("%s_all_cover.png" % key)) if combo_image: if key == "album": self.album_all_cover = gtk.gdk.pixbuf_new_from_file(combo_image) return self.album_all_cover else: self.artist_all_cover = gtk.gdk.pixbuf_new_from_file(combo_image) return self.artist_all_cover return None
def __init__(self, *args, **kwargs): TreeView.__init__(self, *args, **kwargs) targets = [ ("text/deepin-radios", gtk.TARGET_SAME_APP, 1), ] self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP, targets, gtk.gdk.ACTION_COPY) self.connect_after("drag-data-received", self.on_drag_data_received) self.connect("double-click-item", self.on_double_click_item) self.connect("button-press-event", self.on_button_press_event) self.connect("delete-select-items", self.try_emit_empty_signal) self.connect("right-press-items", self.on_right_press_items) Dispatcher.connect("play-radio", self.on_dispatcher_play_radio) Player.connect("play-end", self.on_play_end) self.lock = threading.Lock() self.current_index = 0 self.playlist = [] self.limit_number = 25 self.preview_db_file = get_config_file("preview_radios.db") self.status_db_file = get_cache_file("musicfm/status.db") self.load_status()
def get_pixbuf_from_name(self, query_name, x=None, y=None, return_default=True): x = (x or BROWSER_COVER_SIZE["x"]) y = (y or BROWSER_COVER_SIZE["y"]) filename = get_cache_file("cover/%s.jpg" % query_name.replace("/", "")) if os.path.exists(filename): try: gtk.gdk.pixbuf_new_from_file_at_size(filename, COVER_SIZE["x"], COVER_SIZE["y"]) except gobject.GError: os.unlink(filename) filename = None else: filename = None if filename is None: if return_default: return get_optimum_pixbuf_from_file(self.default_cover) return None else: return get_optimum_pixbuf_from_file(filename, x, y)
def __init__(self, data=None, view_type=1): TreeView.__init__(self, enable_drag_drop=False, enable_multiple_select=True) # view_type 为list类型 self.connect("double-click-item", self.on_music_view_double_click) self.connect("press-return", self.on_music_view_press_return) self.connect("right-press-items", self.on_music_view_right_press_items) #self.connect("delete-select-items", #self.on_music_view_delete_select_items) self.db_file = get_cache_file("neteasecloudmusic/neteasecloudmusic.db") self.view_type = view_type self.view_data = data self.request_thread_id = 0 self.collect_thread_id = 0 self.onlinelist_thread_id = 0 self.collect_page = 0 if self.view_type not in [self.PLAYING_LIST_TYPE, self.LOGIN_LIST_TYPE, self.PERSONAL_FM_ITEM]: self.load_onlinelist_songs() if self.view_type == self.PERSONAL_FM_ITEM: self.enable_multiple_select=False
def __init__(self): self.header = { 'Accept': '*/*', 'Accept-Encoding': 'gzip,deflate,sdch', 'Accept-Language': 'zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'music.163.com', 'Referer': 'http://music.163.com/search/', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' } self.cookie_db_file = get_cache_file("neteasecloudmusic/cookie.db") self.cookies = self.load_cookie() self.modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7' self.nonce = '0CoJUm6Qyw8W8jud' self.pubKey = '010001' self.secKey = self.createSecretKey(16) self.encSecKey = self.rsaEncrypt(self.secKey, self.pubKey, self.modulus) self.session = requests.Session()
def __init__(self, data=None, view_type=1): TreeView.__init__(self, enable_drag_drop=False, enable_multiple_select=True) # view_type 为list类型 self.connect("double-click-item", self.on_music_view_double_click) self.connect("press-return", self.on_music_view_press_return) self.connect("right-press-items", self.on_music_view_right_press_items) #self.connect("delete-select-items", #self.on_music_view_delete_select_items) self.db_file = get_cache_file("neteasecloudmusic/neteasecloudmusic.db") self.view_type = view_type self.view_data = data self.request_thread_id = 0 self.collect_thread_id = 0 self.onlinelist_thread_id = 0 self.collect_page = 0 #self.load_online_playlists() #if self.view_type == self.DEFAULT_TYPE: #self.load() #elif self.view_type == self.COLLECT_TYPE: #self.load_collect_songs() #elif self.view_type == self.PLAYLIST_TYPE: self.load_onlinelist_songs()
def __init__(self): NetEase.__init__(self) self.initial_data() self.config_db = get_cache_file("neteasecloudmusic/conf.db") self.client_version = "0.01" self.is_cloud = 1 self.mv_songs = None self.load()
def __init__(self): self.initial_data() self.config_db = get_cache_file("baidumusic/conf.db") self.client_version = "8.2.0.9" self.is_cloud = 1 self.mv_songs = None self.load()
def get_verify_code(self): url = 'https://passport.baidu.com/?verifypic&t=%d' % utils.timestamp() req = urllib2.Request(url) data = self.opener.open(req).read() pic_image = get_cache_file("pic.jpg") with open(pic_image, "wb") as fp: fp.write(data) if os.path.exists(pic_image): return pic_image else: return None
def __init__(self): self.header = { 'Accept': '*/*', 'Accept-Encoding': 'gzip,deflate,sdch', 'Accept-Language': 'zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'music.163.com', 'Referer': 'http://music.163.com/search/', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' } self.cookie_db_file = get_cache_file("neteasecloudmusic/cookie.db") self.cookies = self.load_cookie()
def get_pixbuf_from_name(self, query_name, x=None, y=None): x = (x or BROWSER_COVER_SIZE["x"]) y = (y or BROWSER_COVER_SIZE["y"]) filename = get_cache_file("cover/%s.jpg" % query_name.replace("/", "")) if os.path.exists(filename): try: gtk.gdk.pixbuf_new_from_file_at_size(filename, COVER_SIZE["x"], COVER_SIZE["y"]) except gobject.GError: os.unlink(filename) filename = self.default_cover else: filename = self.default_cover return get_optimum_pixbuf_from_file(filename, x, y)
def request_song(self, song, play=True): if song: self.set_highlight_song(song) cover_path = get_cache_file("cover") if not os.path.exists(cover_path): os.mkdir(cover_path) for the_file in os.listdir(cover_path): file_path = os.path.join(cover_path, the_file) try: os.unlink(file_path) except: pass song = nplayer.get_better_quality_music(song) nplayer.save_lyric(nplayer.get_lyric(song["sid"]), song["sid"], song["name"], song["artist"]) self.play_song(song, play=True)
def request_song(self, song, play=True): if song: self.set_highlight_song(song) cover_path = get_cache_file('cover') if not os.path.exists(cover_path): os.mkdir(cover_path) for the_file in os.listdir(cover_path): file_path = os.path.join(cover_path, the_file) try: os.unlink(file_path) except: pass song = nplayer.get_better_quality_music(song) nplayer.save_lyric(nplayer.get_lyric(song['sid']), song['sid'], song['name'], song['artist']) self.play_song(song, play=True)
def __init__(self): self.header = { 'Accept': '*/*', 'Accept-Encoding': 'gzip,deflate,sdch', 'Accept-Language': 'zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'music.163.com', 'Referer': 'http://music.163.com/search/', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' } self.cookie_db_file = get_cache_file("neteasecloudmusic/cookie.db") self.cookies = self.load_cookie() self.modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7' self.nonce = '0CoJUm6Qyw8W8jud' self.pubKey = '010001'
def verify_code(self, type, **params): ret = self.api_request("verifycode", type=type, **params) vdata = ret["content"]["validate"] if vdata.get("v_code", None): return ",".join([vdata['v_url'], vdata['v_period'], vdata['v_time'], vdata['v_code']]) else: self.logerror('Verifycode not implemented! type=%s, args=%s', type, params) return None image_url = 'http://vcode.im.baidu.com/cgi-bin/genimg?%s&_time=%s' % (vdata["v_url"], utils.timechecksum()) data = self._opener.open(image_url).read() pic_image = get_cache_file("pic.jpg") with open(pic_image, 'wb') as fp: fp.write(data) self.loginfo('Verify code pic download ok!') code = 'abcd' return ','.join([vdata['v_url'], vdata['v_period'], vdata['v_time'], code])
def request_song(self, song, play=True): if song: self.set_highlight_song(song) cover_path = get_cache_file('cover') if not os.path.exists(cover_path): os.mkdir(cover_path) for the_file in os.listdir(cover_path): file_path = os.path.join(cover_path, the_file) try: os.unlink(file_path) except: pass url = nplayer.get_songs_url([song['sid']])[0]['url'] nplayer.save_lyric(nplayer.get_lyric(song['sid']), song['sid'], song['name'], song['artist']) if not url: self.get_next_song() return song['uri'] = url self.play_song(song, play=True)
def get_combo_all_cover(self, key="album"): cover_cache_dir = get_cache_dir("cover") if not os.path.isdir(cover_cache_dir): return None if len(MediaDB.get_all_uris()) < 4: return None if key == "album": if self.album_all_cover != None: return self.album_all_cover cache_files = [f for f in os.listdir(cover_cache_dir) if "-" in f] elif key == "artist": if self.artist_all_cover != None: return self.artist_all_cover cache_files = [ f for f in os.listdir(cover_cache_dir) if "-" not in f ] else: return None if len(cache_files) < 4: return None random.shuffle(cache_files) combo_image = composite_images( [os.path.join(cover_cache_dir, f) for f in cache_files[:4]], 84, 84, get_cache_file("%s_all_cover.png" % key)) if combo_image: if key == "album": self.album_all_cover = gtk.gdk.pixbuf_new_from_file( combo_image) return self.album_all_cover else: self.artist_all_cover = gtk.gdk.pixbuf_new_from_file( combo_image) return self.artist_all_cover return None
def __init__(self): super(MusicPlaylist, self).__init__() # Set db file self.listen_db_file = get_cache_file( "neteasecloudmusic/local_listen.db") self.status_db_file = get_cache_file("neteasecloudmusic/status.db") # Set default & collect list item self.playing_list_item = MusicListItem("播放列表") #self.created_list_item = MusicListItem("我的歌单", #list_type=MusicListItem.CREATED_LIST_TYPE, #has_separator=True) #self.collected_list_item = MusicListItem("收藏歌单", #list_type=MusicListItem.COLLECTED_LIST_TYPE, #has_separator=True) # Set category list and connect click/right click self.category_list = CategoryView(enable_drag_drop=False, enable_multiple_select=True) self.category_list.add_items([self.playing_list_item]) del self.category_list.keymap["Delete"] self.category_list.draw_mask = self.draw_category_list_mask self.category_list.set_size_request(CATEGROYLIST_WIDTH, -1) self.category_list.connect("single-click-item", self.on_category_single_click) self.category_list.connect("right-press-items", self.on_category_right_press) #self.category_list.set_highlight_item(self.playing_list_item) # Set view_box self.view_box = gtk.VBox() self.view_box.connect("size-allocate", self.on_viewbox_size_allocate) #self.view_box.add(self.playing_list_item.list_widget) main_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True) main_paned.pack1(self.category_list, True, True) main_paned.pack2(self.view_box, True, False) """ Set events""" event_manager.connect("login-success", self.load_online_lists) event_manager.connect("relogin", self.relogin) event_manager.connect("add-and-play", self.add_and_play) event_manager.connect("add-to-playlist", self.add_to_playlist) #event_manager.connect("login-success", #self.on_event_login_success) #event_manager.connect("collect-songs", #self.on_event_collect_songs) #event_manager.connect("add-songs", #self.on_event_add_songs) #event_manager.connect("play-songs", #self.on_event_play_songs) #event_manager.connect("save-listen-lists", #self.on_event_save_listen_lists) event_manager.connect("save-playlist-status", self.save_status) # Load playlists self.online_thread_id = 0 self.new_list_thread_id = 0 if nplayer.is_login: self.load_online_lists('') else: self.login_item = MusicListItem("登录", is_login_item=True) self.category_list.add_items([self.login_item]) self.load() self.load_status() self.add(main_paned)
def get_cover_path(self, song): return get_cache_file("cover/" + self.get_cover_search_str(song) + ".jpg")
def get_cover_path(self, song_or_name): if isinstance(song_or_name, Song): return get_cache_file("cover/" + self.get_cover_search_str(song_or_name) + ".jpg") return get_cache_file("cover/%s.jpg" % song_or_name.replace("/", ""))
def get_cover(self, song, try_web=True, read_local=True): album = self.get_cover_search_str(song) image_path = get_cache_file("cover/%s.jpg" % album) image_path_disable = get_cache_file("cover/%s.jpg.#disable#" % album) if (not song.get_str("title") and not song.get_str("album")) or \ os.path.exists(image_path_disable) or image_path in self.COVER_TO_SKIP: return None # Cover already exist. if read_local: if os.path.exists(image_path): try: gtk.gdk.pixbuf_new_from_file_at_size( image_path, COVER_SIZE["x"], COVER_SIZE["y"]) except gobject.GError: try: os.unlink(image_path) except: pass else: return image_path # Retrieve cover from mp3 tag if read_local: if song.get_scheme() == "file" and song.get_ext() in [ ".mp3", ".tta" ]: found = False fp = None try: fp = file(image_path, "wb+") tag = ID3(song.get_path()) for frame in tag.getall("APIC"): found = True fp.write(frame.data) fp.flush() fp.seek(0, 0) except: if fp: fp.close() else: if fp: fp.close() if found and self.cleanup_cover(song, image_path): return image_path # Search in local directory of the file. if read_local: if song.get("uri") != None and song.get_scheme() == "file": song_dir = song.get_dir() if os.path.exists(song_dir): list_file = os.listdir(song_dir) for pattern in COVER_PATTERNS: matches = fnmatch.filter(list_file, pattern) if matches: matches = sorted( matches, lambda a, b: (len(a) - len(b)) * 10 + cmp(a, b)) if self.cleanup_cover(song, song_dir + "/" + matches[0], image_path): return image_path if not config.getboolean( "setting", "offline") and try_web and is_network_connected(): try: ret = False # try url cover tag if song.get("album_cover_url"): ret = utils.download(song.get("album_cover_url"), image_path) if ret and self.cleanup_cover(song, image_path): return image_path cover_img_url = multi_query_artist_engine(album) if cover_img_url: ret = utils.download(cover_img_url, image_path) if ret and self.cleanup_cover(song, image_path): return image_path except: pass # No cover found self.remove_cover(song) if try_web: self.logdebug("cover not found %s (web: %s)", image_path, try_web) return None
def get_tmp_save_path(name): return get_cache_file("tmp/%s.jpg" % name)
def get_temp_cover_path(self, channel_id): return get_cache_file(os.path.join("douban", "cover", "temp", "%s.png" % channel_id))
def get_cover(self, song, try_web=True): album = self.get_cover_search_str(song) image_path = get_cache_file("cover/%s.jpg" % album) image_path_disable = get_cache_file("cover/%s.jpg.#disable#" % album) if (not song.get_str("title") and not song.get_str("album")) or \ os.path.exists(image_path_disable) or image_path in self.COVER_TO_SKIP: return None # Cover already exist. if os.path.exists(image_path): try: gtk.gdk.pixbuf_new_from_file_at_size(image_path, COVER_SIZE["x"], COVER_SIZE["y"]) except gobject.GError: try: os.unlink(image_path) except: pass else: return image_path # Retrieve cover from mp3 tag if song.get_scheme() == "file" and song.get_ext() in [".mp3", ".tta"]: found = False fp = None try: fp = file(image_path, "wb+") tag = ID3(song.get_path()) for frame in tag.getall("APIC"): found = True fp.write(frame.data) fp.flush() fp.seek(0, 0) except: if fp: fp.close() else: if fp: fp.close() if found and self.cleanup_cover(song, image_path): return image_path # Search in local directory of the file. if song.get("uri") != None and song.get_scheme() == "file": song_dir = song.get_dir() if os.path.exists(song_dir): list_file = os.listdir(song_dir) for pattern in COVER_PATTERNS: matches = fnmatch.filter(list_file, pattern) if matches: matches = sorted(matches, lambda a,b : (len(a) - len(b)) * 10 + cmp(a, b)) if self.cleanup_cover(song, song_dir + "/" + matches[0], image_path): return image_path if not config.getboolean("setting", "offline") and try_web and is_network_connected(): try: ret = False # try url cover tag if song.get("album_cover_url"): ret = utils.download(song.get("album_cover_url"), image_path) if ret and self.cleanup_cover(song, image_path): return image_path cover_img_url = multi_query_artist_engine(album) if cover_img_url: ret = utils.download(cover_img_url, image_path) if ret and self.cleanup_cover(song, image_path): return image_path except: pass # No cover found self.remove_cover(song) if try_web: self.logdebug("cover not found %s (web: %s)", image_path, try_web) return None
def get_cover_save_path(name): return get_cache_file("cover/%s.jpg" % name)
def get_save_file(self, disc_id): disc_hash = "".join(["%d" % key for key in disc_id]) return get_cache_file("cddb/%s" % disc_hash)
def get_cookie_file(name="baidumusic_cookie"): return get_cache_file("%s/%s" % ("baidumusic", name))
import gobject try: import simplejson as json except ImportError: import json import socket socket.setdefaulttimeout(40) # 40s import utils from logger import Logger from xdg_support import get_cache_file __cookies__ = get_cache_file("cookie.txt") class HiLib(gobject.GObject, Logger): __gsignals__ = { "login-check" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (bool,)), "login-verify" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (str,)), "init-finished" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), } def __init__(self, username, password): gobject.GObject.__init__(self) self.username = username.decode("utf-8").encode("gbk") self.password = password # 保存cookie cj = cookielib.LWPCookieJar(__cookies__)
def get_cookie_file(username): return get_cache_file(hashlib.md5(username).hexdigest())
def get_banner_path(self, channel_id): return get_cache_file(os.path.join("douban", "banner", "%s.png" % channel_id))
def get_cookie_file(name="neteasecloudmusic_cookie"): return get_cache_file("%s/%s" % ("neteasecloudmusic", name))
def get_temp_cover_path(self, channel_id): return get_cache_file( os.path.join("douban", "cover", "temp", "%s.png" % channel_id))
def __init__(self): super(MusicPlaylist, self).__init__() self.listen_db_file = get_cache_file("baidumusic/local_listen.db") self.status_db_file = get_cache_file("baidumusic/status.db") # Init default items self.default_list_item = MusicListItem( "试听列表", list_type=MusicListItem.DEFAULT_TYPE) self.collect_list_item = MusicListItem( "我的收藏", list_type=MusicListItem.COLLECT_TYPE, has_separator=True) # Init category list. self.category_list = CategoryView(enable_drag_drop=False, enable_multiple_select=True) self.category_list.add_items( [self.default_list_item, self.collect_list_item]) del self.category_list.keymap["Delete"] self.category_list.draw_mask = self.draw_category_list_mask self.category_list.set_size_request(CATEGROYLIST_WIDTH, -1) self.category_list.connect("single-click-item", self.on_category_single_click) self.category_list.connect("right-press-items", self.on_category_right_press) self.category_list.set_highlight_item(self.default_list_item) # View box self.view_box = gtk.VBox() self.view_box.connect("size-allocate", self.on_viewbox_size_allocate) self.view_box.add(self.default_list_item.list_widget) # bottom_box = gtk.HBox(spacing=45) # bottom_box_align = gtk.Alignment() # bottom_box_align.set(0.5, 0.5, 1, 1) # bottom_box_align.set_padding(2, 2, 28, 0) # bottom_box_align.set_size_request(-1, 22) # bottom_box_align.add(bottom_box) # bottom_box_align.connect("expose_event", self.on_bottombox_expose_event) # self.search_button = create_toggle_button("toolbar/search", parent=bottom_box) # self.person_button = create_button("combo/artist", parent=bottom_box, no_hover=True) main_paned = HPaned(handle_color=app_theme.get_color("panedHandler"), enable_drag=True) main_paned.pack1(self.category_list, True, True) main_paned.pack2(self.view_box, True, False) # events event_manager.connect("login-success", self.on_event_login_success) event_manager.connect("collect-songs", self.on_event_collect_songs) event_manager.connect("add-songs", self.on_event_add_songs) event_manager.connect("play-songs", self.on_event_play_songs) event_manager.connect("save-listen-lists", self.on_event_save_listen_lists) event_manager.connect("save-playlist-status", self.save_status) # load playlists. self.online_thread_id = 0 self.new_list_thread_id = 0 self.load() self.load_online_lists() self.load_status() self.add(main_paned)
import gobject try: import simplejson as json except ImportError: import json import socket socket.setdefaulttimeout(40) # 40s import utils from logger import Logger from xdg_support import get_cache_file __cookies__ = get_cache_file("cookie.txt") class HiLib(gobject.GObject, Logger): __gsignals__ = { "login-check" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (bool,)), "login-verify" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (str,)), "init_finished" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), } def __init__(self, username, password): gobject.GObject.__init__(self) self.username = username.decode("utf-8").encode("gbk") self.password = password # 保存cookie cj = cookielib.LWPCookieJar(__cookies__)
def get_banner_path(self, channel_id): return get_cache_file( os.path.join("douban", "banner", "%s.png" % channel_id))