def init(): api = Api() (email, account, password) = netrc.netrc().hosts['google.com'] logged_in = api.login(email, password) if not logged_in: api = None return api
def __init__(self): self.xbmc = sys.modules["__main__"].xbmc self.xbmcgui = sys.modules["__main__"].xbmcgui self.xbmcplugin = sys.modules["__main__"].xbmcplugin self.settings = sys.modules["__main__"].settings self.language = sys.modules["__main__"].language self.dbg = sys.modules["__main__"].dbg self.common = sys.modules["__main__"].common self.storage = sys.modules["__main__"].storage self.gmusicapi = Api() self.login = GoogleMusicLogin.GoogleMusicLogin(self.gmusicapi)
def init(): """Makes an instance of the api and attempts to login with it. Returns the authenticated api. """ api = Api() logged_in = False attempts = 0 while not logged_in and attempts < 3: email = raw_input("Email: ") password = getpass() logged_in = api.login(email, password) attempts += 1 return api
def __init__(self): self.app = QtGui.QApplication(sys.argv) self.app.setApplicationName("Serenade") signal.signal(signal.SIGINT, signal.SIG_DFL) self.position = 0 self.player = MultimediaKit.QMediaPlayer(self.app) self.player.positionChanged.connect(self.positionChanged) self.signals = Signals() self.client = gconf.client_get_default() self.api = Api() self.artists = [] self.library = {} self.cacheDir = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.CacheLocation) if not os.path.exists(self.cacheDir): os.mkdir(self.cacheDir) self.artistModel = ArtistModel() self.songModel = SongModel() self.signals.onDoneWorking.connect(self.doneWorking) self.signals.onError.connect(self.error) self.view = QtDeclarative.QDeclarativeView() self.view.setSource("/opt/serenade/qml/Main.qml") self.rootObject = self.view.rootObject() self.context = self.view.rootContext() self.context.setContextProperty('songModel', self.songModel) self.context.setContextProperty('artistModel', self.artistModel) self.rootObject.openFile("MenuPage.qml") self.rootObject.refresh.connect(self.updateSongs) self.rootObject.newLogin.connect(self.newLogin) self.rootObject.play.connect(self.play) self.rootObject.togglePause.connect(self.togglePause) self.login() self.view.showFullScreen() sys.exit(self.app.exec_())
def download_by_id(self, key, upload=False): if self.logstack.has_key( key) and self.logstack[key]['state'] != 'fail': return url = 'http://www.youtube.com/watch?v=%s' % (key) if upload: print 'upload google music!!!' self.current_key = key self.logstack[key] = { 'path': '', 'process': '', 'state': 'downloading' } result = None try: self.download([url]) except: self.logstack[key]['state'] = 'fail' return if upload: self.logstack[key]['state'] = 'uploading' print self.logstack[key]['path'] path = self.logstack[key]['path'].encode('utf-8') api = Api() api.login(gpass.id, gpass.passwd) ids = api.get_all_playlist_ids(auto=False, instant=False) playlist_id = ids['user']['youtube'] try: result = api.upload([path]) except: print 'upload error' self.logstack[key]['state'] = 'fail' return if len(result): api.add_songs_to_playlist(playlist_id, result.values()[0]) self.logstack[key]['state'] = 'complete'
def __init__(self): self.storage = sys.modules["__main__"].storage self.gmusicapi = Api(debug_logging=False) self.login = GoogleMusicLogin.GoogleMusicLogin(self.gmusicapi)
def __init__(self, parent=None): QObject.__init__(self, parent) self.settings = SettingsWrapper() self.api = Api()
from gi.repository import GObject, Peas, Gtk, GConf, RB, GLib from concurrent import futures from gmusicapi.api import Api from gettext import lgettext as _ import gettext import rb gettext.bindtextdomain("rhythmbox-gmusic", "/usr/share/locale") gettext.textdomain("rhythmbox-gmusic") api = Api(debug_logging=False) executor = futures.ProcessPoolExecutor(max_workers=1) settings = GConf.Client.get_default() LOGIN_KEY = '/apps/gnome/rhythmbox/google-play-music/login' PASSWORD_KEY = '/apps/gnome/rhythmbox/google-play-music/password' def get_songs(): try: return api.get_all_songs() except KeyError: return [] def get_playlist_songs(id): try: return api.get_playlist_songs(id) except KeyError: return []
def _api_init(self, email, password): """Inits the API object and login to Google Music""" self._api = Api() self._api.login(email, password)