def main(): global vid global fgbg global started global otsu global totHits global spotify spotify = Spotify() totHits = 0 vid = cv2.VideoCapture(0) ret, cap = vid.read() started = False x,y,w,h = 0,0,75,75 otsu = False fgbg = cv2.createBackgroundSubtractorMOG2(100, 10, False) #Main loop for the script while(vid.isOpened()): ret, img = vid.read() if totHits%20 == 1: print "Changing song" spotify.next() frame = img #Place wanted operations here if started: frame = fgbg.apply(frame) frame = cv2.bilateralFilter(frame, 9, 75, 75) if otsu: blur = cv2.GaussianBlur(frame,(7,7),0) ret3, frame = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) if not checkSnowBlindness(frame): calculateBoxContent(frame[x:x+w,y:y+h]) cv2.rectangle(frame,(x,y),(x+w,y+h),(255,255,0),1) frame = cv2.flip(frame, 1) cv2.imshow('SpotiVision', frame) k = cv2.waitKey(30) & 0xff if k in keyPresses: keyPresses[k](frame) quit(1)
def createSpotifyObject(self): try: self.spotify = Spotify() self.bFound = True self.iDelay = 2.0 except: self.bFound = False self.iDelay = 10.0 print self.text.infoStatus
def createSpotifyObject(self): try: self.spotify = Spotify() self.bSpotifyObjectCreated = True print self.text.infoSpotifyObject self.bTerminated = False except: self.bFound = False self.iDelay = 10.0 print self.text.infoStatus
def run(self): while True: try: receivedMessage = self.c.recv(1024).decode("utf-8") print(receivedMessage + "\n") if receivedMessage: Server.getnachrichten(Server).append(receivedMessage) if ('next' in receivedMessage): win32api.keybd_event(self.VK_MEDIA_NEXT_TRACK, self.hwcode1) if ('prev' in receivedMessage): win32api.keybd_event(self.VK_MEDIA_PREV_TRACK, self.hwcode3) if ('pause' in receivedMessage): win32api.keybd_event(self.VK_MEDIA_PLAY_PAUSE, self.hwcode2) if ('stop' in receivedMessage): win32api.keybd_event(self.VK_MEDIA_STOP, self.hwcode4) if ('volup' in receivedMessage): for i in range(0,15): win32api.keybd_event(self.VK_VOLUME_UP, self.hwcode5) x = i if ('voldown' in receivedMessage): for i in range(0,15): win32api.keybd_event(self.VK_VOLUME_DOWN, self.hwcode6) x = i if ('mute' in receivedMessage): win32api.keybd_event(self.VK_VOLUME_MUTE, self.hwcode7) time.sleep(0.5) spotify = Spotify() songInfo = spotify.getCurrentTrack() if songInfo: songInfo += ', Artist: ' + spotify.getCurrentArtist() print(songInfo + "\n") self.c.send(bytes(songInfo)) break; self.c.send(bytes('Error gettin SongInfo')) break; except Exception: traceback.print_exc(file=sys.stdout) break;
import serial import json import requests import time from pytify import Spotify spotify = Spotify() id_ant='' tempo=7 print PuertoSerie.readline() while True: PuertoSerie = serial.Serial('/dev/tty.usbmodem1411', 9600) if PuertoSerie.isOpen == False: PuertoSerie.open() print 'abierto' req = requests.get('https://vast-mesa-3135.herokuapp.com/domotica') jsonData = json.loads(req.text) print jsonData dato = str(jsonData[0]['gesto'].strip()) print dato a,b = dato.split(',') enviar = str(b)+str(a)+'*' if enviar == '11': PuertoSerie.write('0') elif enviar == '10': PuertoSerie.write('1') elif enviar == '21': PuertoSerie.write('2')
from autobahn.websocket import WebSocketClientFactory, \ WebSocketClientProtocol, \ connectWS import os import argparse if not os.name == "posix": from pytify import Spotify else: mac = __import__('MacVersion') spotify = None if os.name == "posix": spotify = mac.MacVersion("Spotify") else: spotify = Spotify() allCommands = [spotify.playpause, spotify.previous, spotify.next, spotify.volumeUp, spotify.volumeDown, spotify.isPlaying, spotify.stop, spotify.mute, spotify.focus] def validCall(parameters): return True def restartFactory():
API_KEY = 'ccd0f44abca06820ffd452952d488177' API_SECRET = '8ea68dc5ec3585ea50565e53682a98e0' #Last.fm username and md5 password hash. username = '******' password_hash = 'd8578edf8458ce06fbc5bb76a58c5ca4' #A Last.fm network object network = pylast.LastFMNetwork(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash) #Create Spotify object spotify = Spotify() # Get current playing track on spotify. track_name = spotify.getCurrentTrack() print track_name.lower() # Get current playing artist on spotify. artist_name = spotify.getCurrentArtist() #Return a track object. track_2_love = network.get_track(artist_name,track_name) #Adds the track to the user's loved tracks track_2_love.love() #Return User Object