当前位置: 首页>>代码示例>>Python>>正文


Python library.MediaDB类代码示例

本文整理汇总了Python中library.MediaDB的典型用法代码示例。如果您正苦于以下问题:Python MediaDB类的具体用法?Python MediaDB怎么用?Python MediaDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MediaDB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self):
     uri =WinFile().run()
     if uri and common.file_is_supported(utils.get_path_from_uri(uri)):
         try:
             MediaDB.get_songs_by_uri(uri)
         except:    
             traceback.print_exc()
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:7,代码来源:local.py

示例2: __on_tag

 def __on_tag(self, bin, taglist):    
     ''' The playbin found the tag information'''
     if not self.song: return 
     if not self.song.get("title") and self.song.get_type() not in ["cue", "cdda", "webcast", "local"]:
         self.logdebug("tag found %s", taglist)
         IDS = {
             "title": "title",
             "genre": "genre",
             "artist": "artist",
             "album": "album",
             "bitrate": "#bitrate",
             'track-number':"#track"
         }
         mod = {}
         for key in taglist.keys():
             if IDS.has_key(key):
                 if key == "lenght":
                     value = int(taglist[key]) * 1000
                 elif key == "bitrate":    
                     value = int(taglist[key] / 100)
                 elif isinstance(taglist[key], long):
                     value = int(taglist[key])
                 else:    
                     value = fix_charset(taglist[key])
                 mod[IDS[key]] = value
         MediaDB.set_property(self.song, mod)        
开发者ID:electricface,项目名称:deepin-music-player,代码行数:26,代码来源:__init__.py

示例3: __init__

 def __init__(self):
     
     TreeView.__init__(self, enable_drag_drop=False, enable_multiple_select=True)        
     targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2), ("text/plain", 0, 3)]        
     self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP,
                        targets, gtk.gdk.ACTION_COPY)
     self.pl = None
     self.add_song_cache = []
     sort_key = ["file", "album", "genre", "#track", "artist", "title", "#playcount", "#added"]
     self.sort_reverse = {key : False for key in sort_key }
     self.connect_after("drag-data-received", self.on_drag_data_received)
     self.connect("double-click-item", self.double_click_item_cb)
     self.connect("button-press-event", self.button_press_cb)
     self.connect("delete-select-items", self.try_emit_empty_signal)
     self.connect("motion-notify-item", self.on_motion_notify_item)
     self.connect("press-return", self.on_press_return)
     self.draw_area.connect("leave-notify-event", self.on_leave_notify_event)
     
     self.set_hide_columns([1])
     self.set_expand_column(None)        
     MediaDB.connect("removed", self.__remove_songs)
     MediaDB.connect("simple-changed", self.__songs_changed)
     
     self.song_notify = SongNotify()
     self.notify_timeout_id = None
     self.notify_timeout = 400 # ms
     self.delay_notify_item = None
     self.notify_offset_x = 5
     self.invaild_items = set()
开发者ID:electricface,项目名称:deepin-music-player,代码行数:29,代码来源:song_view.py

示例4: __init

    def __init(self):        
        # Loaded theme file.
        self.loginfo("Loading application theme...")
        from widget.skin import app_theme        
        
        # Loaded configure.
        self.loginfo("Loading settings...")
        from config import config        
        config.load()
        
        self.__show_splash()

        # Loaded MediaDB.
        self.loginfo("Loading MediaDB...")
        from library import MediaDB
        MediaDB.connect("loaded", self.on_db_loaded)
        MediaDB.load()
        
        # Loaded Chinese to Pinyin DB.
        from pinyin import TransforDB        
        TransforDB.load()        
        
        # initialize Gui
        self.loginfo("Initialize Gui...")
        from widget.instance import DeepinMusic        
        self.app_instance = DeepinMusic()
        self.app_instance.connect("ready", self.on_ready_cb)

        if self.options.StartMinimized:
            self.app_instance.window.iconify()
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:30,代码来源:main.py

示例5: __on_tick

 def __on_tick(self, bin, pos, duration):        
     if self.song:
         if self.song.get_type() == "webcast":
             return
         
     pos /= 1000
     duration /= 1000
     
     if not duration or duration <= 0:
         return
     else:
         if not self.song.get("#duration") or self.song.get("#duration") != duration * 1000:
             if self.song.get_type() != "cue":
                 MediaDB.set_property(self.song, {"#duration": duration * 1000})
                 
     if self.song.get_type() == "cue":            
         duration = self.song.get("#duration") / 1000
         pos = pos - self.song.get("seek", 0)
             
     self.perhap_report(pos, duration)        # todo
     crossfade = self.get_crossfade()
     if crossfade < 0:
         crossfade = 0
     remaining = duration - pos    
     if crossfade:
         if remaining < crossfade:
             if not self.__next_already_called and remaining > 0:
                 self.logdebug("request new song: on tick and play-end not emit")
                 self.emit("play-end")                    
                 self.next()
                 self.__next_already_called = True
开发者ID:electricface,项目名称:deepin-music-player,代码行数:31,代码来源:__init__.py

示例6: __init__

 def __init__(self):
     gobject.GObject.__init__(self)
     
     # Init.
     self.song = None       
     self.fetch_song = None
     self.__source = None 
     self.__need_load_prefs = True 
     self.__current_stream_seeked = False 
     self.__next_already_called = False
     self.__emit_signal_new_song_id = None
     self.skip_error_song_flag = False
     
     self.stop_after_this_track = False
     
     self.__current_song_reported = False
     
     self.__current_duration = None
     
     self.play_thread_id = 0
     
     MediaDB.connect("simple-changed", self.__on_change_songs)
     
     self.bin = PlayerBin()
     self.bin.connect("eos",   self.__on_eos)
     self.bin.connect("error", self.__on_error)
     self.bin.connect("tags-found", self.__on_tag)
     self.bin.connect("tick", self.__on_tick)
     self.bin.connect("playing-stream", self.__on_playing)
开发者ID:electricface,项目名称:deepin-music-player,代码行数:29,代码来源:__init__.py

示例7: update_skipcount

 def update_skipcount(self):        
     '''update skipcount.'''
     # if not played until the end
     if not self.song: return
     if self.song.get_type() != "local": return 
     if not self.__current_song_reported and self.song:
         MediaDB.set_property(self.song, {"#skipcount":self.song.get("#skipcount", 0) + 1})
开发者ID:electricface,项目名称:deepin-music-player,代码行数:7,代码来源:__init__.py

示例8: job

    def job(self):        
        dirs = self.dirs
        added = []
        db_uris = set(MediaDB.get_all_uris())
        alldirs = [ utils.get_path_from_uri(each_dir) for each_dir in dirs ]
        
        for mdir in alldirs:
            for dirpath, dirs, names in os.walk(mdir):
                [ dirs.remove(each_dir) for each_dir in dirs if each_dir[0] == "." ]
                for each_dir in dirs:
                    full_path_dir  = os.path.join(dirpath, each_dir)
                    if os.path.islink(full_path_dir):
                        alldirs.append(os.path.realpath(full_path_dir))

                valid_files = []    
                for name in names:    
                    full_path_file = os.path.join(dirpath, name)
                    if name[0] != "." and common.file_is_supported(full_path_file):
                        valid_files.append(full_path_file)
                    yield full_path_file    
                        
                valid_files = set(valid_files)    
                for each_file in valid_files:
                    real_file = os.path.realpath(each_file)
                    uri = utils.get_uri_from_path(real_file)
                    if real_file not in db_uris:
                        added.append(uri)
                    elif os.path.getctime(real_file) > MediaDB.get_song(uri).get("#ctime"):
                        added.append(uri)

        added = set(added)
        for uri in added:
            self.add_to_library(uri)
            yield utils.get_path_from_uri(uri)
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:34,代码来源:local.py

示例9: remove_songs

 def remove_songs(self, fully=False):
     if len(self.select_rows) > 0:
         songs = [ self.items[self.select_rows[index]].get_song() for index in range(0, len(self.select_rows))]
         MediaDB.remove(songs)    
         if fully:
             [ utils.move_to_trash(song.get("uri")) for song in songs if song.get_type() != "cue" ]
         self.delete_select_items()            
     return True    
开发者ID:electricface,项目名称:deepin-music-player,代码行数:8,代码来源:song_view.py

示例10: __init__

 def __init__(self):
     uri = WinFile().run()
     if uri and common.file_is_supported(utils.get_path_from_uri(uri)):
         tags = {"uri": uri}
         try:
             MediaDB.get_or_create_song(tags, "local", read_from_file=True)
         except:
             traceback.print_exc()
开发者ID:hillwoodroc,项目名称:deepin-music-player,代码行数:8,代码来源:local.py

示例11: real_remove_item

 def real_remove_item(self, item, fully=False):    
     songs = self.get_item_songs(item)
     MediaDB.remove(songs)
     
     if fully:
         try:
             [ utils.move_to_trash(song.get("uri")) for song in songs if song.get_type() != "cue" ]
         except: pass    
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:8,代码来源:local_browser.py

示例12: remove_cover

 def remove_cover(self, song, emit=False):
     image_path = self.get_cover_path(song)
     if os.path.exists(image_path):    
         try:
             os.unlink(image_path)
         except:    
             pass
     if emit:    
         MediaDB.set_property(song, {"album" : song.get("album")})
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:9,代码来源:cover_manager.py

示例13: perhap_report

 def perhap_report(self, pos=None, duration=None):
     '''report song'''
     if not duration:
         duration = self.get_length()
     if not pos:    
         pos = self.get_position()
     if self.song and not self.__current_stream_seeked and not self.__next_already_called and not self.__current_song_reported and duration > 10 and pos and pos >= min(duration / 2, 240 * 1000):    
         MediaDB.set_property(self.song, {"#playcount": self.song.get("#playcount", 0) + 1})
         MediaDB.set_property(self.song, {"#lastplayed":time()})
         self.__current_song_reported = True
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:10,代码来源:__init__.py

示例14: __idle_quit

 def __idle_quit(self, *args):    
     self.loginfo("Exiting...")
     Player.stop()
     self.mmkeys.release()
     self.playlist_ui.save_to_library()
     MediaDB.save()
     config.write()
     global_hotkeys.stop()
     self.window.destroy()        
     gtk.main_quit()
     self.loginfo("Exit successful.")
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:11,代码来源:instance.py

示例15: save_to_library

 def save_to_library(self):    
     if self.search_flag:
         self.reset_search_entry()
               
     MediaDB.full_erase_playlists()
     for item in self.category_list.get_items():
         if item.udi is not None:
             continue
         songs = item.get_songs()
         name = item.get_title()
         MediaDB.create_playlist("local", name, songs)
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:11,代码来源:playlist.py


注:本文中的library.MediaDB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。