Example #1
0
 def on_load(self):
     self.login_text.set_text(FCBase().lfm_login)
     self.password_text.set_text(FCBase().lfm_password)
     self.adjustment.set_value(FC().search_limit)
     self.music_scrobbler.set_active(FC().enable_music_scrobbler)
     self.radio_scrobbler.set_active(FC().enable_radio_scrobbler)
     self.vk_autocomplete.set_active(FC().enable_vk_autocomlete)
Example #2
0
    def init_thread(self):
        logging.debug("RUN INIT LAST.FM")
        username = FCBase().lfm_login
        password_hash = pylast.md5(FCBase().lfm_password)
        self.cache = None
        try:
            
            self.network = pylast.get_lastfm_network(api_key=API_KEY, api_secret=API_SECRET, username=username, password_hash=password_hash)
            self.cache = Cache(self.network)
            if FC().proxy_enable and FC().proxy_url:
                proxy_rul = FC().proxy_url
                index = proxy_rul.find(":")
                proxy = proxy_rul[:index]
                port = proxy_rul[index + 1:]
                self.network.enable_proxy(proxy, port)
                logging.info("Enable proxy for last fm" + str(proxy) + str(port))


            """scrobbler"""
            scrobbler_network = pylast.get_lastfm_network(username=username, password_hash=password_hash)
            self.scrobbler = scrobbler_network.get_scrobbler("fbx", "1.0")
        except:
            self.network = None
            self.scrobbler = None
            self.controls.statusbar.set_text("Error last.fm connection with %s/%s" % (username, FCBase().lfm_password))
            logging.error("Invalid last fm login or password or network problems" + username + FCBase().lfm_password)
            """
            val = show_login_password_error_dialog(_("Last.fm connection error"), _("Verify user and password"), username, FC().lfm_password)
            if val:
                FC().lfm_login = val[0]
                FC().lfm_password = val[1]
            return False
            """

        return True
Example #3
0
    def on_save(self):
        if FCBase().vk_login != self.login_text.get_text() or FCBase(
        ).vk_password != self.password_text.get_text():
            FC().cookie = None

        FCBase().vk_login = self.login_text.get_text()
        FCBase().vk_password = self.password_text.get_text()
Example #4
0
    def on_save(self):
        if FCBase().lfm_login != self.login_text.get_text() or FCBase().lfm_password != self.password_text.get_text():
            FCBase().cookie = None

        FCBase().lfm_login = self.login_text.get_text()
        FCBase().lfm_password = self.password_text.get_text()
        FC().search_limit = self.adjustment.get_value()
        FC().enable_music_scrobbler = self.music_scrobbler.get_active()
        FC().enable_radio_scrobbler = self.radio_scrobbler.get_active()
        FC().enable_vk_autocomlete  = self.vk_autocomplete.get_active()
Example #5
0
    def on_save(self):
        if FCBase().lfm_login != self.login_text.get_text() or FCBase(
        ).lfm_password != self.password_text.get_text():
            FCBase().cookie = None

        FCBase().lfm_login = self.login_text.get_text()
        FCBase().lfm_password = self.password_text.get_text()

        FC().enable_music_scrobbler = self.music_scrobbler.get_active()
        FC().enable_radio_scrobbler = self.radio_scrobbler.get_active()
Example #6
0
 def login(self):
     post = {
         'email': FCBase().vk_login,
         'pass': FCBase().vk_password,
         'act': 'login',
         'q': '1',
         'al_frame': '1'
     }
     self.get('http://login.vk.com/?act=login', post)
     if (not self.is_connected()):
         logging.error("failed connection to vk")
Example #7
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)
Example #8
0
    def check_version(self):
        uuid = FCBase().uuid
        current_version = FOOBNIX_VERSION
        system = "not_set"
        try:
            import platform
            system = platform.system()
        except:
            pass

        try:
            from socket import gethostname
            f = urlopen("http://www.foobnix.com/version?uuid=" + uuid +
                        "&host=" + gethostname() + "&version=" +
                        current_version + "&platform=" + system,
                        timeout=7)
            #f = urllib2.urlopen("http://localhost:8080/version?uuid=" + uuid + "&host=" + gethostname() + "&v=" + current_version)
        except Exception as e:
            logging.error("Check version error: " + str(e))
            return None

        new_version_line = f.read()

        logging.info("version " + current_version + "|" + new_version_line +
                     "|" + str(uuid))

        f.close()
        if FC().check_new_version and compare_versions(current_version,
                                                       new_version_line) == 1:
            info_dialog_with_link_and_donate(new_version_line)
Example #9
0
        def task():
            old_iters = self.get_child_iters_by_parent(
                self.model, self.get_iter_from_bean(parent))
            childs = self.services[u"" + parent.text](FCBase().lfm_login)
            update_parent_for_beans(childs, parent)

            self.append_all(childs)
            gobject.idle_add(self.remove_iters, old_iters)
Example #10
0
 def task():
     old_iters = self.get_child_iters_by_parent(
         self.model, self.get_iter_from_bean(parent))
     childs = self.services[parent.text](FCBase().lfm_login,
                                         str(int(FC().search_limit)))
     update_parent_for_beans(childs, parent)
     self.append_all(childs)
     GLib.idle_add(self.remove_iters, old_iters)
Example #11
0
 def get(self, url, data=None, headers={}):
     if data:
         data = urllib.urlencode(data)
     time.sleep(0.6)
     try:
         handler = self.opener.open(url, data)
         data = handler.read()
         handler.close()
         return data
     except HTTPError, e:
         logging.error("VK Connection Error:" + str(e) + "( Searching: " +
                       str(url) + " with data " + str(data) + ") [" +
                       FCBase().vk_login + ":" + FCBase().vk_password + "]")
         if e.code == 400:
             FCBase().vk_login, FCBase().vk_password = get_random_vk()
             self.initialize_urllib2()
             self.login()
         return None
Example #12
0
    def init_thread(self):
        username = FCBase().lfm_login
        password = FCBase().lfm_password

        if not username or username == "l_user_" or not password:
            logging.debug("No last.fm account provided")
            return None

        if not self.controls.net_wrapper.is_internet():
            # try again...
            time.sleep(5)
            if not self.controls.net_wrapper.is_internet():
                return None

        logging.debug("RUN INIT LAST.FM")
        password_hash = pylast.md5(password)
        self.cache = None
        try:
            self.network = pylast.get_lastfm_network(
                api_key=API_KEY,
                api_secret=API_SECRET,
                username=username,
                password_hash=password_hash)
            self.cache = Cache(self.network)
            """scrobbler"""
            scrobbler_network = pylast.get_lastfm_network(
                username=username, password_hash=password_hash)
            self.scrobbler = scrobbler_network.get_scrobbler("fbx", "1.0")
        except:
            self.network = None
            self.scrobbler = None
            self.controls.statusbar.set_text(
                "Error last.fm connection with %s/%s" %
                (username, FCBase().lfm_password))
            logging.error(
                "Either invalid last.fm login or password or network problems")
            """
            val = show_login_password_error_dialog(_("Last.fm connection error"), _("Verify user and password"), username, FC().lfm_password)
            if val:
                FC().lfm_login = val[0]
                FC().lfm_password = val[1]
            return False
            """
        return True
Example #13
0
def send(d={"t": "appview"}):
    params = {
        "v": "1",
        "tid": "UA-36625986-1",
        "cid": FCBase().uuid,
        "ul": SITE_LOCALE,
        "an": "Foobnix",
        "av": FOOBNIX_VERSION,
        "cd1": platform.python_version(),
        "cd2": platform.platform()
    }
    params.update(d)

    #logging.debug("analytics params: "+str(params));
    enq = urllib.urlencode(params)
    thread.start_new_thread(urllib2.urlopen, (api_url, enq))
Example #14
0
 def play(self, bean):
     self.statusbar.set_text("")
     if not bean:
         self.state_stop()
         return None
     
     if not bean.is_file: 
         self.state_stop()
         return None
     
     if not bean.path:
         bean.path = get_bean_posible_paths(bean)
                 
     if not bean.path:            
         if not self.fill_bean_from_vk(bean):
             if self.count_errors < 4:
                 logging.debug("Error happen [%s] %s" % (self.count_errors, FCBase().vk_login))
                 time.sleep(0.5)
                 self.count_errors += 1
                 self.next()
             
     
     if bean.path and os.path.isdir(bean.path):
         self.state_stop()
         return None
     
     if bean.type == FTYPE_RADIO:
         self.record.show()
     else:
         self.record.hide()
             
     self.seek_bar.clear()
     self.count_errors = 0
     self.statusbar.set_text(bean.info)
     self.trayicon.set_text(bean.text)
     
     self.movie_window.set_text(bean.text)        
     self.main_window.set_title(bean.text)
     
     self.media_engine.play(bean)  
     self.is_scrobbled = False
     self.start_time = False      
     
     self.update_info_panel(bean)
     if not get_file_extension(bean.path) in FC().video_formats:
         self.set_visible_video_panel(False)
Example #15
0
def send(d={"t": "appview"}):
    params = {
        "v": "1",
        "tid": "UA-36625986-1",
        "cid": FCBase().uuid,
        "ul": SITE_LOCALE,
        "an": "Foobnix",
        "av": FOOBNIX_VERSION,
        "cd1": platform.python_version(),
        "cd2": platform.platform()
    }
    params.update(d)

    #logging.debug("analytics params: "+str(params));
    enq = urllib.parse.urlencode(params).encode("utf-8")
    threading.Thread(target=urllib.request.urlopen,
                     args=(api_url, enq)).start()
Example #16
0
 def check_version(self):
     uuid = FCBase().uuid
     current_version = FOOBNIX_VERSION
     system = "not_set"
     try:
         import platform
         system = platform.system()
     except:
         pass
             
     try:
         from socket import gethostname
         f = urllib2.urlopen("http://www.foobnix.com/version?uuid=" + uuid + "&host=" + gethostname() + "&version=" + current_version + "&platform=" + system)
         #f = urllib2.urlopen("http://localhost:8080/version?uuid=" + uuid + "&host=" + gethostname() + "&v=" + current_version)
     except Exception, e:
         logging.error("Check version error" + str(e))
         return None
Example #17
0
    def __init__(self, controls):
        CommonTreeControl.__init__(self, controls)
        """column config"""
        column = gtk.TreeViewColumn(_("VK Integration ") + FCBase().vk_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.lazy = False
        self.cache = []
Example #18
0
'''
Created on Nov 9, 2013

@author: ivan
'''
import unittest
from foobnix.thirdparty import pylast
from foobnix.fc.fc_base import FCBase
from foobnix.thirdparty.pylast import Artist

API_KEY = FCBase().API_KEY
API_SECRET = FCBase().API_SECRET
username = FCBase().lfm_login
password_hash = pylast.md5(FCBase().lfm_password)

class Test(unittest.TestCase):

    def test_pylast(self):
        network = pylast.get_lastfm_network(api_key=API_KEY,
                                                     api_secret=API_SECRET,
                                                     username=username,
                                                     password_hash=password_hash)
        artist = network.get_artist("Madonna");
        summary = artist.get_bio_summary()
        print("=========")
        print(summary)

Example #19
0
    def __init__(self, activate_perspective, controls):

        gtk.HBox.__init__(self, False, 0)

        self.active = None

        musics = PespectiveToogledButton(_("Music"), gtk.STOCK_HARDDISK,
                                         _("Music Navigation (Alt+1)"))
        musics.connect(
            "clicked",
            lambda *a: activate_perspective(LEFT_PERSPECTIVE_NAVIGATION))
        musics.set_active(True)

        radios = PespectiveToogledButton(_("Radio"), gtk.STOCK_NETWORK,
                                         _("Radio Stantions (Alt+2)"))
        radios.connect("clicked",
                       lambda *a: activate_perspective(LEFT_PERSPECTIVE_RADIO))

        virtuals = PespectiveToogledButton(_("Playlist"), gtk.STOCK_INDEX,
                                           _("Virtual Play Lists (Alt+3)"))
        virtuals.connect(
            "clicked",
            lambda *a: activate_perspective(LEFT_PERSPECTIVE_VIRTUAL))

        info = PespectiveToogledButton(_("Info"), gtk.STOCK_INFO,
                                       _("Info Panel (Alt+4)"))
        info.connect("clicked",
                     lambda *a: activate_perspective(LEFT_PERSPECTIVE_INFO))

        lastfm = PespectiveToogledButton(_("Last.Fm"), gtk.STOCK_CONNECT,
                                         _("Last.fm Panel (Alt+5)"))
        lastfm.connect(
            "clicked",
            lambda *a: activate_perspective(LEFT_PERSPECTIVE_LASTFM))

        vk = PespectiveToogledButton(_("VK"), gtk.STOCK_UNINDENT,
                                     _("VK Panel (Alt+6)"))
        vk.connect("clicked", lambda *a: controls.vk_integration.lazy_load())
        vk.connect("clicked",
                   lambda *a: activate_perspective(LEFT_PERSPECTIVE_VK))

        self.button_list = {
            LEFT_PERSPECTIVE_NAVIGATION: musics,
            LEFT_PERSPECTIVE_RADIO: radios,
            LEFT_PERSPECTIVE_VIRTUAL: virtuals,
            LEFT_PERSPECTIVE_LASTFM: lastfm,
            LEFT_PERSPECTIVE_VK: vk,
            LEFT_PERSPECTIVE_INFO: info
        }

        OneActiveToggledButton(self.button_list.values())

        self.pack_start(musics, False, False, 0)
        self.pack_start(radios, False, False, 0)

        if "l_user_" != FCBase().lfm_login:
            self.pack_start(lastfm, False, False, 0)

        self.pack_start(vk, False, False, 0)

        self.pack_start(virtuals, False, False, 0)
        self.pack_start(info, False, False, 0)
Example #20
0
@author: ivan
'''
import thread
import logging

from foobnix.thirdparty import pylast
from foobnix.thirdparty.pylast import WSError, Tag
from foobnix.regui.model import FModel
from foobnix.thirdparty.google.translate import translate
from foobnix.fc.fc_base import FCBase
from foobnix.fc.fc import FC
from foobnix.util.file_utils import file_extension
from foobnix.util.const import FTYPE_VIDEO

API_KEY = FCBase().API_KEY
API_SECRET = FCBase().API_SECRET

class Cache():
    def __init__(self, network):
        self.network = network
        self.cache_tracks = {}
        self.cache_albums = {}
        self.cache_images = {}

    def get_key(self, artist, title):
        return artist + "-" + title

    def get_track(self, artist, title):
        if not artist or not title:
            return None
Example #21
0
from foobnix.gui.service.vk_service import VKService
from foobnix.fc.fc_base import FCBase
FCBase().vk_login, FCBase().vk_password = "******", ""
vk_service = VKService(True)
i = 0
for line in vk_service.api.get("video.get", uid=6851750):
    i += 1
    if line == 25:
        continue
    print(line['title'])
    print(line['image'])
    print(line['link'])
    print(line)
    print(i)
    if i == 3:
        break
Example #22
0
 def on_load(self):
     self.login_text.set_text(FCBase().vk_login)
     self.password_text.set_text(FCBase().vk_password)
Example #23
0
File: fc.py Project: shenps/foobnix
 def save(self):
     FCStates().save(self, CONFIG_FILE)
     FCBase().save()
     FCache().save()
Example #24
0
 def on_load(self):
     self.login_text.set_text(FCBase().lfm_login)
     self.password_text.set_text(FCBase().lfm_password)
     self.music_scrobbler.set_active(FC().enable_music_scrobbler)
     self.radio_scrobbler.set_active(FC().enable_radio_scrobbler)