Skip to content

Commit

Permalink
Fixed two bugs:
Browse files Browse the repository at this point in the history
 - used to stop playing on --without-spotify when hitting a non-cached song,
 - search used to go to free spotify api even when using --without-spotify.
  • Loading branch information
highfestiva committed Sep 6, 2016
1 parent be76dfc commit d93da59
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions absong.py
Expand Up @@ -8,3 +8,7 @@ def __init__(self, _name,_artist,_uri):
self.uri = _uri
def __eq__(self, other):
return self.name == other.name and self.artist == str(other.artist)
def __str__(self):
return self.artist + ' ' + self.name
def __repr__(self):
return self.__str__()
20 changes: 12 additions & 8 deletions aidband.py
Expand Up @@ -43,7 +43,7 @@


def stop():
global proc,cache_write_name
global proc,cache_write_name,active_url
if proc:
try:
proc.kill()
Expand All @@ -52,16 +52,17 @@ def stop():
print(e)
proc = None
try:
import os
os.system('killall mplayer')
subprocess.check_output('killall mplayer'.split(), shell=True, stderr=subprocess.STDOUT)
except:
pass
if cache_write_name:
import os
try: os.remove(cache_write_name)
except: pass
cache_write_name = None
elif muzaks:
muzaks.stop()
active_url = ''

def spotify_init():
global options,muzaks
Expand Down Expand Up @@ -109,9 +110,8 @@ def play_url(url, cachename):
ok = True
elif url:
print('Get me mplayer!')
if url:
start_play_time = time.time()
active_url = url
start_play_time = time.time()
active_url = url if url else cachename
return ok

def remove_from_cache(song):
Expand Down Expand Up @@ -145,7 +145,9 @@ def poll():
next_song()
return

if not proc or proc.poll() == None:
if not proc and not active_url:
return
if proc and proc.poll() == None:
return
global cache_write_name
if cache_write_name and os.path.exists(cache_write_name):
Expand Down Expand Up @@ -397,11 +399,12 @@ def handle_keys(k):
stopped = True
while True:
try:
time.sleep(0.2) # Let CPU rest in case of infinite loop bug.
output('Enter search term:')
cmd = ''
while not cmd:
event.wait(2)
time.sleep(0.2) # Hang on a pinch to see if there's more to be had.
time.sleep(0.2) # Let CPU rest in case of infinite loop bug.
if not stopped:
poll()
cmd = keypeeker.peekstr() + netpeeker.peekstr()
Expand Down Expand Up @@ -470,3 +473,4 @@ def handle_keys(k):
netpeeker.getstr() # Clear remote keyboard.
except Exception as e:
print('FATAL ERROR!')
time.sleep(1)
2 changes: 2 additions & 0 deletions keypeeker.py
Expand Up @@ -28,6 +28,7 @@
def getch():
s = ''
while not s:
sleep(0.01)
s = sys.stdin.read(1)
if not s:
sleep(0.1)
Expand Down Expand Up @@ -99,6 +100,7 @@ def readkeys(handle_keys):
keytimeout.reset()
global keys
while True:
sleep(0.01)
ch = getch()
if ord(ch) == 0:
ch = getch()
Expand Down
Binary file added mplayer.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions netpeeker.py
Expand Up @@ -4,6 +4,7 @@
from killable import KillableThread
import re
import socket
from time import sleep
from timeout import Timeout
from threading import Thread

Expand Down Expand Up @@ -40,8 +41,10 @@ def handlecmd(client, handle_login, handle_keys):
print('Remote network shell authenticated and running.')
handle_login()
while True:
sleep(0.001)
bb += client.recv(1)
if not bb:
sleep(0.1)
raise 'Disconnected?'
try:
i = bb.decode()
Expand Down Expand Up @@ -76,12 +79,14 @@ def listen(handle_login, handle_keys):
s.bind(('',3303))
s.listen(2)
while 1:
sleep(0.1)
client,address = s.accept()
print('New remote network shell connected.')
try:
client.send('Password: '.encode())
pw,i = '',0
while '\r' not in pw and len(pw)<50 and i<50:
sleep(0.01)
pw += client.recv(1).decode()
i += 1
client.send('\n'.encode())
Expand Down
1 change: 1 addition & 0 deletions sock.py
Expand Up @@ -56,5 +56,6 @@ def recvchunk(self):
except _socket.error:
break
self.timeout = 0.1
sleep(0.001)
self.timeout = to
return s

0 comments on commit d93da59

Please sign in to comment.