def simple_scanner(path, level): try: path = path.encode("utf-8") except: pass results = [] if not os.path.exists(path): return dir = os.path.abspath(path) list = sort_by_name(path, os.listdir(dir)) for file in list: full_path = os.path.join(path, file) if os.path.isfile(full_path): if file_extension(file) not in FC().all_support_formats: continue; if os.path.isdir(full_path): if is_dir_with_music(full_path): b_bean = FModel(file, full_path).add_parent(level).add_is_file(False) results.append(b_bean) results.extend(simple_scanner(full_path, b_bean.get_level())) elif os.path.isfile(full_path): results.append(FModel(file, full_path).add_parent(level).add_is_file(True)) return results
def task(bean): if bean.artist and bean.title: if bean.path and file_extension( bean.path) in FC().video_formats: #skip video scrobbler return if bean.type == FTYPE_VIDEO: #skip video results return try: bean.artist, bean.title = bean.artist.encode( "utf-8"), bean.title.encode("utf-8") self.get_scrobbler().scrobble(bean.artist, bean.title, start_time, "P", "", int(duration_sec)) logging.debug("Song Scrobbled " + str(bean.artist) + " " + str(bean.title) + " " + str(start_time) + " P: " + str(int(duration_sec))) except Exception, e: logging.error( str(e) + "Error reporting now playing last.fm " + str(bean.artist) + " " + str(bean.title) + " A: " + str(bean.album))
def _scanner(path, level): results = [] if not os.path.exists(path): return dir = os.path.abspath(path) list = sort_by_name(path, os.listdir(dir)) for file in list: full_path = os.path.join(path, file) if os.path.isfile(full_path): #pr_window.analyzed_files += 1 if file_extension(file) not in FC().all_support_formats: continue if os.path.isdir(full_path): #pr_window.analyzed_folders += 1 if is_dir_with_music(full_path): #pr_window.media_folders += 1 b_bean = FModel(file, full_path).add_parent(level).add_is_file(False) results.append(b_bean) results.extend(_scanner(full_path, b_bean.get_level())) elif os.path.isfile(full_path): results.append(FModel(file, full_path).add_parent(level).add_is_file(True)) #pr_window.media_files +=1 return results
def get_support_music_beans_from_all(beans): result = [] for bean in beans: if bean.path and os.path.isdir(bean.path): result.append(bean) elif bean.path and os.path.isfile(bean.path) and file_extension(bean.path) in FC().audio_formats: result.append(bean) elif bean.path and bean.path.startswith("http://"): result.append(bean) else: result.append(bean) return result
def task(bean): if bean.artist and bean.title: if bean.path and file_extension(bean.path) in FC().video_formats: #skip video scrobbler return; if bean.type == FTYPE_VIDEO: #skip video results return ; try: bean.artist , bean.title = bean.artist.encode("utf-8") , bean.title.encode("utf-8") self.get_scrobbler().scrobble(bean.artist, bean.title, start_time, "P", "", int(duration_sec)) logging.debug("Song Scrobbled " + str(bean.artist) + " " + str(bean.title) + " " + str(start_time) + " P: " + str(int(duration_sec))) except Exception, e: logging.error(str(e) + "Error reporting now playing last.fm " + str(bean.artist) + " " + str(bean.title) + " A: " + str(bean.album))
def is_dir_with_music(path): list = None try: list = os.listdir(path) except OSError as e: logging.info("Can't get list of dir"+ str(e)) if not list: return False for file in list: full_path = os.path.join(path, file) if os.path.isdir(full_path): if is_dir_with_music(full_path): return True else: if file_extension(file) in FC().all_support_formats: return True return False
def is_dir_with_music(path): if os.path.isdir(path): list = None try: list = os.listdir(path) except OSError, e: logging.info("Can't get list of dir"+ str(e)) if not list: return False for file in list: full_path = os.path.join(path, file) if os.path.isdir(full_path): if is_dir_with_music(full_path): return True else: if file_extension(file) in FC().all_support_formats: return True
def _scanner(path, level): path = unicode(path) results = [] if not os.path.exists(path): return None dir = os.path.abspath(path) list = os.listdir(dir) list = sort_by_name(path, list) for file in list: full_path = os.path.join(path, file) if os.path.isfile(full_path) and file_extension(file) not in FC().all_support_formats: continue; if is_dir_with_music(full_path): b_bean = FModel(file, full_path).add_parent(level).add_is_file(False) results.append(b_bean) results.extend(_scanner(full_path, b_bean.get_level())) elif os.path.isfile(full_path): results.append(FModel(file, full_path).add_parent(level).add_is_file(True)) return results
list = None try: list = os.listdir(path) except OSError, e: logging.info("Can't get list of dir"+ str(e)) if not list: return False for file in list: full_path = os.path.join(path, file) if os.path.isdir(full_path): if is_dir_with_music(full_path): return True else: if file_extension(file) in FC().all_support_formats: return True return False class ProgWindow(ChildTopWindow): def __init__(self, controls): ChildTopWindow.__init__(self, "Progress", 500, 100) self.set_transient_for(controls.main_window) self.label = gtk.Label("Total analyzed folders: ") self.label1 = gtk.Label("Total analyzed files: ") self.label2 = gtk.Label("Folders with media files found: ") self.label3 = gtk.Label("Media files found: ") self.analyzed_files_label = gtk.Label("0")
list = None try: list = os.listdir(path) except OSError, e: logging.info("Can't get list of dir" + str(e)) if not list: return False for file in list: full_path = os.path.join(path, file) if os.path.isdir(full_path): if is_dir_with_music(full_path): return True else: if file_extension(file) in FC().all_support_formats: return True return False class ProgWindow(ChildTopWindow): def __init__(self, controls): ChildTopWindow.__init__(self, "Progress", 500, 100) self.set_transient_for(controls.main_window) self.label = Gtk.Label.new("Total analyzed folders: ") self.label1 = Gtk.Label.new("Total analyzed files: ") self.label2 = Gtk.Label.new("Folders with media files found: ") self.label3 = Gtk.Label.new("Media files found: ")