Ejemplo n.º 1
0
    def enterVerificationCode(self, verificationCode):
        if self.app.osInfo.report['internet'] == True:
            if self.authProcess is None:
                return 'No Auth Process in curse'

            # Delete old configuration
            execute('rm /root/.config/spotify-cli/credentials.json')

            print("[spotify] Setting Auth Code: " + verificationCode)
            # Enter Verification Code
            os.write(self.authProcessMaster, verificationCode.encode('utf-8'))
            # Proceed
            os.write(self.authProcessMaster, '\n'.encode('utf-8'))

            time.sleep(1)
            x = os.read(self.authProcessMaster, 1026)

            print("[spotify] Ending Auth Process")
            os.close(self.authProcessMaster)
            self.authProcess.terminate()
            self.authProcess.wait()
            return 'Auth Process done!'
        else:
            print('[spotify] No internet connection')
            return 'no-internet-connection'
Ejemplo n.º 2
0
 def pause(self):
     if self.app.osInfo.report['internet'] == True:
         output = execute(BIN_DIR + 'spotify pause')
         self.parse_spotify_status(output)
         print('[spotify] STOP')
     else:
         print('[spotify] No internet connection')
Ejemplo n.º 3
0
 def searchSpotify(self, type, terms):
     if self.app.osInfo.report['internet'] == True:
         return execute(BIN_DIR + 'spotify search ' + terms + ' --' + type +
                        ' --raw')
     else:
         print('[spotify] No internet connection')
         return {}
Ejemplo n.º 4
0
 def previous(self):
     if self.app.osInfo.report['internet'] == True:
         output = execute(BIN_DIR + 'spotify previous')
         self.parse_spotify_status(output)
         print('[spotify] PREVIOUS: ' + self.getStatus()['currentArtist'] +
               ' - ' + self.getStatus()['currentTrack'])
     else:
         print('[spotify] No internet connection')
Ejemplo n.º 5
0
 def set_local_device(self):
     if self.app.osInfo.report['internet'] == True:
         output = execute(BIN_DIR + 'spotify device -s raspotify')
         if len(output.splitlines()) > 0:
             print('[spotify] Setting Spotify device to Raspotify: ' +
                   output.splitlines()[0])
         else:
             print('[spotify] Problem during set local device: ')
     else:
         print('[spotify] No internet connection')
Ejemplo n.º 6
0
 def check_local_device(self):
     if self.app.osInfo.report['internet'] == True:
         output = execute(BIN_DIR + 'spotify device')
         if 'raspotify' in output:
             return True
         else:
             restart_service('raspotify')
             time.sleep(3)
             self.set_local_device()
             return False
     else:
         print('[spotify] No internet connection')
Ejemplo n.º 7
0
 def play(self, uri=None):
     if self.app.osInfo.report['internet'] == True:
         self.check_local_device()
         command = BIN_DIR + 'spotify play'
         if (uri != None):
             command = command + ' --uri ' + uri
         output = execute(command)
         self.parse_spotify_status(output)
         print('[spotify] PLAY: ' + self.getStatus()['currentArtist'] +
               ' - ' + self.getStatus()['currentTrack'])
         return self.getStatus()
     else:
         print('[spotify] No internet connection')
Ejemplo n.º 8
0
 def getAuth(self):
     if self.app.osInfo.report['internet'] == True:
         output = execute(BIN_DIR + 'spotify auth status')
         if (output == ''):
             output = 'Not logged in.'
         return {
             'status': output,
         }
     else:
         print('[spotify] No internet connection')
         return {
             'status': 'No internet connection',
         }