コード例 #1
0
    def add_m3u(self, from_model, from_iter, to_model, to_iter, pos):
        if ((from_model.get_value(from_iter, 0).lower().endswith(".m3u")
             or from_model.get_value(from_iter, 0).lower().endswith(".m3u8"))
                and from_model.get_model() is not to_model):
            m3u_file_path = from_model.get_value(from_iter, 5)
            m3u_title = from_model.get_value(from_iter, 0)

            if m3u_file_path.startswith("http"):
                return None

            paths = m3u_reader(m3u_file_path)
            paths.insert(0, os.path.splitext(m3u_title)[0])
            list = paths[0].split("/")
            name = list[len(list) - 2]
            parent = FModel(name)
            new_iter = None
            for i, path in enumerate(paths):
                if not i:
                    bean = FModel(path)
                else:
                    bean = FModel(path, path).parent(parent)

                row = self.get_row_from_bean(bean)

                if new_iter:
                    to_iter = new_iter
                new_iter = self.to_add_drag_item(to_model,
                                                 to_iter,
                                                 pos,
                                                 None,
                                                 row=row)

            return True
コード例 #2
0
    def search_top_albums(self, aritst_name):
        if not self.connect():
            return None
        artist = self.network.get_artist(aritst_name)
        if not artist:
            return None
        try:
            albums = artist.get_top_albums()
        except WSError:
            logging.info("No artist with that name")
            return None

        beans = []
        for album in albums:
            try:
                album_txt = album.item
            except AttributeError:
                album_txt = album['item']

            name = album_txt.get_name()
            #year = album_txt.get_release_year()
            year = None
            if year:
                bean = FModel(name + "(" + year + ")").add_album(name).add_artist(aritst_name).add_year(year)
            else:
                bean = FModel(name).add_album(name).add_artist(aritst_name).add_year(year)

            beans.append(bean)
        return beans
コード例 #3
0
ファイル: vk_service.py プロジェクト: inferno1988/foobnix
    def find_tracks_by_query(self, query):
        def post():
            self.find_tracks_by_query(self, query)
            
        if self.is_show_authorization(post):
            return 
        
        logging.info("start search songs " + query)
        query = urllib.quote(query.encode("utf-8"))
        
        list = self.get_result("audio.search", "q=" + query)
        childs = []
        
        if not list:
            return childs

        for line in list[1:]:                      
            bean = FModel(line['artist'] + ' - ' + line['title'])
            bean.aritst = line['artist']
            bean.title = line['title']
            bean.time = convert_seconds_to_text(line['duration'])
            bean.path = line['url']
            childs.append(bean)
             
        return childs
コード例 #4
0
ファイル: vk_service.py プロジェクト: inferno1988/foobnix
 def find_tracks_by_url(self, url):
     logging.debug("Search By URL")
     
     index = url.rfind("#")
     if index > 0:
         url = url[:index]
     index = url.find("id=")
     if index < 0:
         return None
     
     id = url[index + 3:]
     id = int(id)
     if id > 0:
         results = self.get_result('audio.get', "uid="+str(id))
     else:
         results = self.get_result('audio.get', "gid="+str(abs(id)))
         
     childs = []
     for line in results:
         bean = FModel(line['artist'] + ' - ' + line['title'])
         bean.aritst = line['artist']
         bean.title = line['title']
         bean.time = convert_seconds_to_text(line['duration'])
         bean.path = line['url']
         childs.append(bean)
          
    
     return childs 
コード例 #5
0
ファイル: music_service.py プロジェクト: atis/foobnix
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
コード例 #6
0
    def update_music_tree(self, tree=None, number_of_page=0):
        if not tree:
            tree = self.tree

        logging.info("Update music tree" +
                     str(FCache().music_paths[number_of_page]))
        tree.clear_tree()
        FCache().cache_music_tree_beans[number_of_page] = []

        all = []

        all = get_all_music_by_paths(FCache().music_paths[number_of_page],
                                     self)

        for bean in all:
            FCache().cache_music_tree_beans[number_of_page].append(bean)
        try:
            self.perspective.hide_add_button()
        except AttributeError:
            logging.warn("Object perspective not exists yet")

        if not all:
            tree.is_empty = True
            try:
                self.perspective.show_add_button()
            except AttributeError:
                logging.warn("Object perspective not exists yet")
            all.append(FModel(_("Music not found in folder(s):")))
            for path in FCache().music_paths[number_of_page]:
                all.append(FModel(path).add_is_file(True))
        else:
            tree.is_empty = False

        tree.append_all(all)
        tree.ext_width = tree.ext_column.get_width()
コード例 #7
0
def _scanner(path, level):
    try:
        path = path.encode("utf-8")
    except:
        pass

    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
コード例 #8
0
ファイル: radio_tree.py プロジェクト: jose2190/foobnix
 def on_add_station(self):
     name, url = two_line_dialog("Add New Radio Station", "Enter Name and URL", "", "http://")
     with open(CACHE_RADIO_FILE, 'a') as f:
         f.write('#' + name + '\n' + url + '\n')
     bean = FModel(name, url).add_is_file(True)
     bean.type=FTYPE_RADIO
     self.append(bean)
コード例 #9
0
 def on_add_station(self):
     name, url = two_line_dialog("Add New Radio Station",
                                 "Enter Name and URL", "", "http://")
     with open(CACHE_RADIO_FILE, 'a') as f:
         f.write('#' + name + '\n' + url + '\n')
     bean = FModel(name, url).add_is_file(True)
     bean.type = FTYPE_RADIO
     self.append(bean)
コード例 #10
0
ファイル: base_controls.py プロジェクト: cyberbolt/foobnix
 def on_add_files(self, paths=None, tab_name=None):
     
     if not paths:       
         paths = file_chooser_dialog(_("Choose file to open"), FC().last_dir)
         if not paths: return
     copy_paths = copy.deepcopy(paths)
     
     for i, path in enumerate(copy_paths):
         if path.lower().endswith(".m3u") or path.lower().endswith(".m3u8"):
             paths[i:i + 1] = m3u_reader(path)
             if len(copy_paths) == 1:
                 ext = os.path.splitext(path)[1]
                 tab_name = os.path.basename(path)[:-len(ext)]
             break
     
     if paths:
         if paths[0]:
             if isinstance(paths[0], list):
                 path = paths[0][0]
             else:
                 path = paths[0]
         else:
             if isinstance(path, list):
                 path = paths[1][0]
             else:
                 path = paths[1]
            
         if path:
             list_path = path.split("/")
             name = list_path[len(list_path) - 2]
             if not tab_name:
                 tab_name = os.path.split(os.path.dirname(path))[1]
             FC().last_dir = path[:path.rfind("/")]
             self.append_to_new_notebook(tab_name, [])
             parent = FModel(name)
             self.append_to_current_notebook([parent])
         else:
             self.append_to_new_notebook(tab_name, [])
             parent = FModel(tab_name)
             self.append_to_current_notebook([parent])
                           
         beans = []
         for path in paths:
             text = None 
             if isinstance(path, list):
                 text = path[1]
                 path = path[0]
                 bean = FModel(path, path).add_is_file(True)
             else:
                 bean = FModel(path, path).parent(parent).add_is_file(True)
             if text: 
                 bean.text = text
             beans.append(bean)
         if not beans:
             self.append_to_current_notebook([FModel(_("Nothing found to play in the file(s)") + paths[0])])
         else:
             self.append_to_current_notebook(beans)
コード例 #11
0
    def show_google_results(self, query):
        beans = []
        beans.append(FModel('"%s" not found trying Google search' % query))
        g_results = google_search_results(query)
        for line in g_results:
            beans.append(FModel(line).add_is_file(True))
        if not g_results:
            beans.append(FModel('Google not found %s' % query))

        return beans
コード例 #12
0
ファイル: radio_tree.py プロジェクト: atis/foobnix
 def auto_add_user_station(self):
     if os.path.isfile(CACHE_RADIO_FILE) and os.path.getsize(CACHE_RADIO_FILE) > 0:
         with open(CACHE_RADIO_FILE, 'r') as f:
             list = f.readlines()
             parent_level_for_depth = {}
             previous = {"bean": None, "depth": 0, "name": '', "url": ''} 
             for line in list:
                 depth = self.simbol_counter(line, '-')
                 try:
                     name = line[depth : line.index('#')]
                 except ValueError, e:
                     logging.warning('\'#\' ' + str(e) + ' in line \"' + line + '\"')
                     continue
                 url = line[line.index('#') + 1 : -1]
                 bean = FModel(name)
                 if url:
                     bean.add_is_file(True).add_path(url).add_type(FTYPE_RADIO)
                 if previous["depth"] < depth:
                     bean.add_parent(previous["bean"].level)
                 elif previous["depth"] > depth:
                     bean.add_parent(parent_level_for_depth[depth]) 
                 else:
                     if previous["bean"]:
                         bean.add_parent(previous["bean"].parent_level)
                     
                 self.append(bean)
                 parent_level_for_depth[depth] = bean.parent_level
                 previous = {"bean": bean, "depth": depth, "name": name, "url": url}
コード例 #13
0
 def get_users_by_uuid(uuidd):
     for user in self.controls.vk_service.get_result('getProfiles','uids='+uuidd):
         logging.debug(user)
         name =  user['first_name']+ " "+ user['last_name']
     
         parent = FModel(name)
         parent.user_id = user['uid']
         bean = FDModel(_("loading...")).parent(parent).add_is_file(True)
         
         self.append(parent)        
         self.append(bean)
コード例 #14
0
 def task():
     for fpl in files:
         parent = FModel(fpl.name).add_is_file(False)
         self.append(parent)
         for radio, urls in fpl.urls_dict.iteritems():
             child = FModel(
                 radio, urls[0]).parent(parent).add_type(FTYPE_RADIO)
             self.append(child)
     self.auto_add_user_station()
     FC().cache_radio_tree_beans = self.get_all_beans()
     self.is_radio_populated = True
コード例 #15
0
ファイル: radio_tree.py プロジェクト: atis/foobnix
 def create_new_group(self):
     name = one_line_dialog(_("Create Group"), self.controls.main_window, message_text1=_("Enter group name"))
     if not name:
         return
     bean = self.get_selected_bean()
     folder_bean = FModel(name)
     if bean:
         if bean.is_file:
             folder_bean.add_parent(bean.parent_level)
         else:
             folder_bean.add_parent(bean.level)
     self.append(folder_bean)
コード例 #16
0
        def get_users_by_uuid(uuidd):
            for user in self.controls.vk_service.api.get('getProfiles',
                                                         uids=uuidd):
                logging.debug(user)
                name = user['first_name'] + " " + user['last_name']

                parent = FModel(name)
                parent.user_id = user['uid']
                bean = FDModel(_("loading...")).parent(parent)

                self.append(parent)
                self.append(bean)
コード例 #17
0
ファイル: navigation_tree.py プロジェクト: atis/foobnix
 def create_folder(self, a):
     model, tree_path, row = a
     file_path = row[self.path[0]]
     new_folder_path = create_folder_dialog(file_path)
     bean = FModel(os.path.basename(new_folder_path), new_folder_path).add_is_file(False)
     if os.path.isfile(file_path):
         bean.add_parent(row[self.parent_level[0]])
     elif os.path.isdir(file_path):
         bean.add_parent(row[self.level[0]])
     else:
         logging.error("So path doesn't exist")
     self.tree_append(bean)
     self.save_beans_from_tree()
コード例 #18
0
    def add_m3u(self,
                from_model=None,
                from_iter=None,
                to_tree=None,
                to_model=None,
                to_iter=None,
                pos=None,
                row=None):
        if row:
            if get_file_extension(row[self.path[0]]) in [".m3u", ".m3u8"]:
                m3u_file_path = row[self.path[0]]
                m3u_title = row[self.text[0]]
            else:
                return
        else:
            if ((from_model.get_value(from_iter, 0).lower().endswith(".m3u") or
                 from_model.get_value(from_iter, 0).lower().endswith(".m3u8"))
                    and from_model.get_model() is not to_model):
                m3u_file_path = from_model.get_value(from_iter, self.path[0])
                m3u_title = from_model.get_value(from_iter, self.text[0])
            else:
                return

            if m3u_file_path.startswith("http//"):
                return None

        paths = m3u_reader(m3u_file_path)
        paths.insert(0, os.path.splitext(m3u_title)[0])
        first_path = paths[0][0] if isinstance(paths[0], list) else paths[0]
        if first_path:
            list_path = first_path[0].split("/")
            name = list_path[len(list_path) - 2]
            parent = FModel(name)

        new_iter = None
        for i, path in enumerate(paths):
            if isinstance(path, list):
                text = path[1]
                path = path[0]
                bean = FModel(path, path).add_is_file(True)
                if text: bean.text = text

            elif not i:
                bean = FModel(_("m3u playlist: ") +
                              path).add_is_file(False).add_font("bold")
            else:
                bean = FModel(path, path).parent(parent)

            row = self.fill_beans_and_get_rows([bean])[0]

            if new_iter:
                to_iter = new_iter
            new_iter = self.to_add_drag_item(to_tree,
                                             to_model,
                                             to_iter,
                                             pos,
                                             None,
                                             row=row)

        return True
コード例 #19
0
 def add_m3u(self, from_model=None, from_iter=None, to_tree=None, to_model=None,
             to_iter=None, pos=None, row=None):
     if row:
         if get_file_extension(row[self.path[0]]) in [".m3u", ".m3u8"]:
             m3u_file_path = row[self.path[0]]
             m3u_title = row[self.text[0]]
         else:
             return
     else:
         if ((from_model.get_value(from_iter, 0).lower().endswith(".m3u") 
         or from_model.get_value(from_iter, 0).lower().endswith(".m3u8"))
         and from_model.get_model() is not to_model):
                 m3u_file_path = from_model.get_value(from_iter, self.path[0])
                 m3u_title = from_model.get_value(from_iter, self.text[0])
         else:
             return
         
         if m3u_file_path.startswith("http//"):
             return None
         
     paths = m3u_reader(m3u_file_path)
     paths.insert(0, os.path.splitext(m3u_title)[0])
     first_path = paths[0][0] if isinstance(paths[0], list) else paths[0]
     if first_path:
         list_path = first_path[0].split("/")
         name = list_path[len(list_path) - 2]
         parent = FModel(name)
         
     new_iter = None
     for i, path in enumerate(paths):
         if isinstance(path, list):
             text = path[1]
             path = path[0]
             bean = FModel(path, path).add_is_file(True)
             if text: bean.text = text
             
                     
         elif not i:
             bean = FModel(_("m3u playlist: ") + path).add_is_file(False).add_font("bold")
         else:
             bean = FModel(path, path).add_is_file(True).parent(parent)
         
         row = self.fill_beans_and_get_rows([bean])[0]                               
                    
         if new_iter:
             to_iter = new_iter
         new_iter = self.to_add_drag_item(to_tree, to_model, to_iter, pos, None,  row=row)
         
     return True
コード例 #20
0
    def on_add_files(self, paths=None, tab_name=None):

        if not paths:
            paths = file_chooser_dialog(_("Choose file to open"),
                                        FC().last_dir)
            copy_paths = copy.deepcopy(paths)
            for i, path in enumerate(copy_paths):
                if path.lower().endswith(".m3u") or path.lower().endswith(
                        ".m3u8"):
                    paths[i:i + 1] = m3u_reader(path)
                    if len(copy_paths) == 1:
                        ext = os.path.splitext(path)[1]
                        tab_name = os.path.basename(path)[:-len(ext)]
                    break
        if paths:
            if paths[0]:
                if isinstance(paths[0], list):
                    path = paths[0][0]
                else:
                    path = paths[0]
            else:
                if isinstance(path, list):
                    path = paths[1][0]
                else:
                    path = paths[1]

            if path:
                list_path = path.split("/")
                name = list_path[len(list_path) - 2]
                if not tab_name:
                    tab_name = os.path.split(os.path.dirname(path))[1]
                FC().last_dir = path[:path.rfind("/")]
                self.append_to_new_notebook(tab_name, [])
                parent = FModel(name)
                self.append_to_current_notebook([parent])
            else:
                self.append_to_new_notebook(tab_name, [])
                parent = FModel(tab_name)
                self.append_to_current_notebook([parent])

            beans = []
            for path in paths:
                text = None
                if isinstance(path, list):
                    text = path[1]
                    path = path[0]
                    bean = FModel(path, path).add_is_file(True)
                else:
                    bean = FModel(path, path).parent(parent).add_is_file(True)
                if text:
                    bean.text = text
                beans.append(bean)
            if not beans:
                self.append_to_current_notebook([
                    FModel(
                        _("Nothing found to play in the file(s)") + paths[0])
                ])
            else:
                self.append_to_current_notebook(beans)
コード例 #21
0
 def task():
     old_iters = self.get_child_iters_by_parent(self.model, self.get_iter_from_bean(parent));
     childs = []
     for line in self.controls.vk_service.api.get('audio.get',uid=parent.user_id):
         bean = FModel(line['artist']+' - '+line['title'])
         bean.aritst = line['artist']
         bean.title = line['title']
         bean.time = convert_seconds_to_text(line['duration'])
         bean.path = line['url']
         childs.append(bean)
                 
     update_parent_for_beans(childs, parent)
     
     self.append_all(childs)            
     gobject.idle_add(self.remove_iters,old_iters)        
コード例 #22
0
     def task():
         path = paths[0]
         list = path.split("/")
         FC().last_dir = path[:path.rfind("/")]
         name = list[len(list) - 1]
         parent = FModel(name)
         self.append_to_new_notebook(name, [])
 
         all_beans = []
         all_beans.append(parent)
         for path in paths:
             if path == "/":
                 logging.info("Skip root folder")
                 continue;
             beans = get_all_music_by_path(path)
             
             for bean in beans:
                 if not bean.is_file:
                     bean.parent(parent).add_is_file(False)
                 all_beans.append(bean)
 
         if all_beans:
             self.append_to_current_notebook(all_beans)
         else:
             self.append([self.SearchCriteriaBeen(_("Nothing found to play in the folder(s)") + paths[0])])
コード例 #23
0
    def search_top_similar_tags(self, artist, title):
        if not self.connect():
            return None

        if not artist or not title:
            logging.warn("search_top_similar_tags artist or title is empty")
            return []

        track = self.cache.get_track(artist, title)

        if not track:
            logging.warn("search_top_similar_tags track not found")
            return []

        tags = track.get_top_tags()
        beans = []
        for tag in tags:
            try:
                tag_item = tag.item
            except AttributeError:
                tag_item = tag['item']

            tag_name = tag_item.get_name()
            model = FModel(tag_name).add_genre(tag_name).add_is_file(True)
            beans.append(model)
        return beans
コード例 #24
0
    def search_top_tracks(self, artist_name):
        if not self.connect():
            return None
        artist = self.network.get_artist(artist_name)
        if not artist:
            return []
        try:
            tracks = artist.get_top_tracks()
        except WSError:
            logging.info("No artist with that name")
            return []

        beans = []

        for track in tracks:

            try:
                track_item = track.item
            except AttributeError:
                track_item = track['item']

            #LOG.info(track_item.get_duration())

            #bean = CommonBean(name=str(track_item), path="", type=CommonBean.TYPE_MUSIC_URL, parent=query);
            artist = track_item.get_artist().get_name()
            title = track_item.get_title()
            text = artist + " - " + title
            bean = FModel(text).add_artist(artist).add_title(title)
            beans.append(bean)

        return beans
コード例 #25
0
 def artists_to_models(self, artists):
     results = []
     for track in artists:
         artist = track.get_name()
         bean = FModel(artist).add_artist(artist)
         results.append(bean)
     return results
コード例 #26
0
    def search_top_tag_tracks(self, tag_name):
        if not self.connect():
            return None
        if not tag_name:
            logging.warn("search_top_tags TAG is empty")
            return []

        tag = Tag(tag_name, self.network)
        tracks = tag.get_top_tracks()

        beans = []

        for track in tracks:

            try:
                track_item = track.item
            except AttributeError:
                track_item = track['item']

            #LOG.info(track_item.get_duration())

            #bean = CommonBean(name=str(track_item), path="", type=CommonBean.TYPE_MUSIC_URL, parent=query);
            artist = track_item.get_artist().get_name()
            title = track_item.get_title()
            text = artist + " - " + title
            bean = FModel(text).add_artist(artist).add_title(title)
            beans.append(bean)

        return beans
コード例 #27
0
ファイル: tray_icon.py プロジェクト: jose2190/foobnix
class TrayIconControls(gtk.StatusIcon, ImageBase, FControl, LoadSave):
    def __init__(self, controls):
        FControl.__init__(self, controls)
        gtk.StatusIcon.__init__(self)
        self.hide()

        ImageBase.__init__(self, ICON_FOOBNIX, 150)

        self.popup_menu = PopupMenuWindow(self.controls)
        self.popup_volume_contol = PopupVolumeWindow(self.controls,
                                                     self.popup_menu)

        self.connect("activate", self.on_activate)
        self.connect("popup-menu", self.on_popup_menu)

        try:
            self.set_has_tooltip(True)
            self.tooltip = gtk.Tooltip()
            self.set_tooltip("Foobnix music player")
            self.connect("query-tooltip", self.on_query_tooltip)
            self.connect("button-press-event", self.on_button_press)
            self.connect("scroll-event", self.on_scroll)
        except Exception, e:
            logging.warn("On debian it doesn't work" + str(e))

        self.current_bean = FModel().add_artist("Artist").add_title("Title")
        self.tooltip_image = ImageBase(ICON_FOOBNIX, 75)
コード例 #28
0
 def get_bean_from_row(self, row):
     bean = FModel()
     id_dict = FTreeModel().cut().__dict__
     for key in id_dict.keys():
         num = id_dict[key]
         setattr(bean, key, row[num])
     return bean
コード例 #29
0
ファイル: lastfm_service.py プロジェクト: jose2190/foobnix
    def search_top_similar_artist(self, artist_name, count=45):
        if not self.connect():
            return None
        if not artist_name:
            logging.warn("search_top_similar_artist, Artist name is empty")
            return []

        artist = self.network.get_artist(artist_name)
        if not artist:
            return []

        artists = artist.get_similar(count)
        beans = []
        for artist in artists:
            try:
                artist_txt = artist.item
            except AttributeError:
                artist_txt = artist['item']

            artist_name = artist_txt.get_name()
            bean = FModel(artist_name).add_artist(artist_name).add_is_file(
                True)

            beans.append(bean)
        return beans
コード例 #30
0
    def search_top_similar_tracks(self, artist, title):
        if not self.connect():
            return None

        if not artist or not title:
            logging.warn("search_top_similar_tags artist or title is empty")
            return []

        track = self.cache.get_track(artist, title)
        if not track:
            logging.warn("search_top_similar_tracks track not found")
            return []

        similars = track.get_similar()
        beans = []
        for tsong in similars:
            try:
                tsong_item = tsong.item
            except AttributeError:
                tsong_item = tsong['item']

            artist = tsong_item.get_artist().get_name()
            title = tsong_item.get_title()
            model = FModel(artist + " - " + title).add_artist(artist).add_title(title).add_is_file(True)
            beans.append(model)

        return beans
コード例 #31
0
    def __init__(self, controls):
        CommonTreeControl.__init__(self, controls)
        """column config"""
        column = gtk.TreeViewColumn(_("Lasm.fm Integration ") +
                                    FCBase().lfm_login,
                                    gtk.CellRendererText(),
                                    text=self.text[0],
                                    font=self.font[0])
        column.set_resizable(True)
        self.set_headers_visible(True)
        self.append_column(column)

        self.configure_send_drag()
        self.configure_recive_drag()

        self.set_type_tree()

        self.services = {
            _("My loved tracks"):
            self.controls.lastfm_service.get_loved_tracks,
            _("My top tracks"): self.controls.lastfm_service.get_top_tracks,
            _("My recent tracks"):
            self.controls.lastfm_service.get_recent_tracks,
            _("My top artists"): self.controls.lastfm_service.get_top_artists
            # _("My friends"):self.controls.lastfm_service.get_friends,
            #_("My neighbours"):self.controls.lastfm_service.get_neighbours
        }

        for name in self.services:
            parent = FModel(name)
            bean = FDModel(_("loading...")).parent(parent).add_is_file(True)
            self.append(parent)
            self.append(bean)
コード例 #32
0
 def get_friends(self, username):
     lfm_tracks = self.get_user(username).get_friends()
     list = self.get_sub_childs(lfm_tracks, 'name')
     result = []
     for item in list:
         result.append(FModel(item))
     return result
コード例 #33
0
 def get_neighbours(self, username):
     lfm_tracks = self.get_user(username).get_neighbours()
     list = self.get_sub_childs(lfm_tracks, 'name')
     result = []
     for item in list:
         parent = FModel(item)
         result.append(parent)
     return result
コード例 #34
0
 def tracks_to_models(self, tracks):
     results = []
     for track in tracks:
         artist = track.get_artist().get_name()
         title = track.get_title()
         bean = FModel(artist + " - " + title).add_artist(artist).add_title(title)
         results.append(bean)
     return results
コード例 #35
0
 def create_folder(self, a):
     model, tree_path, row = a
     file_path = row[self.path[0]]
     new_folder_path = create_folder_dialog(file_path)
     if os.path.isfile(file_path):
         iter = model.get_iter(tree_path)
         parent = model.iter_parent(iter)
     elif os.path.isdir(file_path):
         parent = model.get_iter(tree_path)
     else:
         logging.error("So path doesn't exist")
     bean = FModel(os.path.basename(new_folder_path), new_folder_path).add_parent(row[self.level[0]]).add_is_file(False)
     bean.font = "bold"
     bean.visible = True
     row = self.get_row_from_bean(bean)
     model.prepend(parent, row)
     self.save_beans_from_tree()
コード例 #36
0
ファイル: radio_tree.py プロジェクト: atis/foobnix
 def on_add_station(self):
     name, url = two_line_dialog(_("Add New Radio Station"),
                                 parent = self.controls.main_window,
                                 message_text1 = _("Enter station name and URL"),
                                 message_text2 = None,
                                 entry_text1 = None, 
                                 entry_text2 = "http://")
     if not name or not url:
         return
     bean = self.get_selected_bean()
     new_bean = FModel(name, url).add_type(FTYPE_RADIO).add_is_file(True)
     if bean:
         if bean.is_file:
             new_bean.add_parent(bean.parent_level)
         else:
             new_bean.add_parent(bean.level)
     self.append(new_bean)
コード例 #37
0
ファイル: vk_service.py プロジェクト: matttbe/foobnix
 def generate_track(self, html):
     video = self.get_json(html)
     if video:
         link = self.get_link(video)
         title = self.get_title(html)
         time = self.get_time(html)
         if link and title:
             return FModel(title, link).add_time(time)
     return None
コード例 #38
0
ファイル: infopanel.py プロジェクト: matttbe/foobnix
 def show_similar_tracks(self):
     if self.info_cache.similar_tracks_bean == self.bean:
         return None
     self.info_cache.similar_tracks_bean = self.bean
     """similar  songs"""
     similar_tracks = self.controls.lastfm_service.search_top_similar_tracks(
         self.bean.artist, self.bean.title)
     parent = FModel("Similar Tracks: " + self.bean.title)
     update_parent_for_beans(similar_tracks, parent)
     self.tracks.populate_all([parent] + similar_tracks)
コード例 #39
0
ファイル: infopanel.py プロジェクト: matttbe/foobnix
 def show_similar_artists(self):
     if self.info_cache.similar_artists_bean == self.bean:
         return None
     self.info_cache.similar_artists_bean = self.bean
     """similar  artists"""
     similar_artists = self.controls.lastfm_service.search_top_similar_artist(
         self.bean.artist)
     parent = FModel("Similar Artists: " + self.bean.artist)
     update_parent_for_beans(similar_artists, parent)
     self.artists.populate_all([parent] + similar_artists)
コード例 #40
0
ファイル: infopanel.py プロジェクト: jose2190/foobnix
 def show_best_songs(self):         
     if self.info_cache.best_songs_bean == self.bean:
         return None
     
     self.info_cache.best_songs_bean = self.bean
     
     best_songs = self.controls.lastfm_service.search_top_tracks(self.bean.artist)
     parent = FModel("Best Songs: " + self.bean.artist)
     update_parent_for_beans(best_songs, parent)
     self.best_songs.populate_all([parent] + best_songs)
コード例 #41
0
 def create_folder(self, a):
     model, tree_path, row = a
     file_path = row[self.path[0]]
     new_folder_path = create_folder_dialog(file_path)
     if os.path.isfile(file_path):
         iter = model.get_iter(tree_path)
         parent = model.iter_parent(iter)
     elif os.path.isdir(file_path):
         parent = model.get_iter(tree_path)
     else:
         logging.error("So path doesn't exist")
     bean = FModel(os.path.basename(new_folder_path),
                   new_folder_path).add_parent(
                       row[self.level[0]]).add_is_file(False)
     bean.font = "bold"
     bean.visible = True
     row = self.get_row_from_bean(bean)
     model.prepend(parent, row)
     self.save_beans_from_tree()
コード例 #42
0
ファイル: vk_service.py プロジェクト: matttbe/foobnix
 def generate_track(self, html):
     ids = re.findall("return operate\(([\w() ,']*)\);", html,
                      re.IGNORECASE)[0]
     url = self.track_url(ids)
     artist = self.field('<b id="performer[_0-9]*">', html)
     title = self.field('<span id="title[_0-9]*">', html)
     duration = self.field('<div class="duration">', html)
     text = artist + " - " + title
     return FModel(
         text, url).add_artist(artist).add_title(title).add_time(duration)
コード例 #43
0
 def get_bean_from_model_iter(self, model, iter):
     if not model or not iter:
         return None
     bean = FModel()
     id_dict = FTreeModel().cut().__dict__
     for key in id_dict.keys():
         num = id_dict[key]
         val = model.get_value(iter, num)
         setattr(bean, key, val)
     return bean
コード例 #44
0
ファイル: cue_reader.py プロジェクト: Lomir/foobnix
 def get_common_beans(self):
     beans = []
     cue = self.parse()
     if not self.is_cue_valid():
         return []
     for i, track  in enumerate(cue.tracks):
         bean = FModel(text=track.performer + " - " + track.title, path=track.path)
         bean.artist = track.performer
         bean.tracknumber = i + 1
         bean.title = track.title
         bean.name = bean.text
         bean.start_sec = track.get_start_time_sec()
         bean.duration_sec = track.duration
         bean.time = convert_seconds_to_text(track.duration)
         bean.is_file = True
         beans.append(bean)
     
     return beans
コード例 #45
0
ファイル: music_service.py プロジェクト: Lomir/foobnix
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
コード例 #46
0
ファイル: dragdrop_tree.py プロジェクト: Pythoning/foobnix
    def add_m3u(self, from_model=None, from_iter=None, to_tree=None, to_model=None,
                to_iter=None, pos=None, row=None):
        if row:
            m3u_file_path = row[self.path[0]]
            m3u_title = row[self.text[0]]

        else:
            if from_model.get_model() is not to_model:
                m3u_file_path = from_model.get_value(from_iter, self.path[0])
                m3u_title = from_model.get_value(from_iter, self.text[0])
            else:
                return
            
        if m3u_file_path.startswith("http//"):
            return None
            
        paths = m3u_reader(m3u_file_path)
        paths.insert(0, [None, os.path.splitext(m3u_title)[0]])
            
        new_iter = None
        for i, path in enumerate(paths):
            if i == 0:
                bean = FModel(_("m3u playlist: ") + path[1]).add_is_file(False).add_font("bold")
            else:
                text = path[1]
                path = path[0]
                bean = FModel(path, path).add_is_file(True)
                if path.startswith("http"):
                    bean.add_type(FTYPE_RADIO)
                if text: bean.text = text
                        
            row = self.fill_beans_and_get_rows([bean])[0]                               
                       
            if new_iter:
                to_iter = new_iter
            new_iter = self.to_add_drag_item(to_tree, to_model, to_iter, pos, None,  row=row)
            
        return True
コード例 #47
0
ファイル: vk_service.py プロジェクト: matttbe/foobnix
 def find_tracks_by_query(self, query):
     if not self.is_connected():
         return []
     logging.info("start search songs" + query)
     page = self.search(query)
     if not page:
         return []
      
     results = self.api.get('audio.search',q=query, count=50)
         
     childs = []
     
     for i, line in enumerate(results):
         if i ==0:
             continue
         
         bean = FModel(line['artist']+' - '+line['title'])
         bean.aritst = line['artist']
         bean.title = line['title']
         bean.time = convert_seconds_to_text(line['duration'])
         bean.path = line['url']
         childs.append(bean)
          
     return childs
コード例 #48
0
 def task():
     for line in self.controls.vk_service.get_result('audio.get',"uid="+parent.user_id):
         logging.debug(line);
         bean = FModel(line['artist']+' - '+line['title'])
         
         bean.aritst = line['artist']
         bean.title = line['title']
         bean.time = convert_seconds_to_text(line['duration'])
         bean.path = line['url']
         bean.is_file = True
         
         row = self.get_row_from_bean(bean);
         self.model.append(p_iter, row)
     
     for rem in old_iters:
         self.model.remove(rem)   
コード例 #49
0
ファイル: cue_reader.py プロジェクト: inferno1988/foobnix
 def get_common_beans(self):
     beans = []
     cue = self.parse()
     if not self.is_cue_valid():
         return []
     for i, track  in enumerate(cue.tracks):
         bean = FModel(text=track.performer + " - " + track.title, path=track.path)
         bean.artist = track.performer
         bean.tracknumber = i + 1
         bean.title = track.title
         bean.album = self.cue_file.title
         bean.name = bean.text
         bean.start_sec = track.get_start_time_sec()
         bean.duration_sec = track.duration
         bean.time = convert_seconds_to_text(track.duration)
         bean.is_file = True
         try:
             bean.info = foobnix.util.id3_util.normalized_info(get_mutagen_audio(track.path).info, bean)
         except Exception, e:
             logging.warn(str(e) + " " + bean.path)
             bean.info = ""
                                    
         if not bean.title or not bean.artist:
             bean = udpate_id3(bean)
         
         beans.append(bean)