Skip to content

Instantly share code, notes, and snippets.

@tjb0607
Last active August 29, 2015 14:11
Show Gist options
  • Save tjb0607/ffcc8299d30503b1a7cf to your computer and use it in GitHub Desktop.
Save tjb0607/ffcc8299d30503b1a7cf to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import subprocess
import urllib.request
import time
import re
import sys
from multiprocessing import Process
def openurl(plaintext):
match = re.search("(https?|ftp)://(www\.)?honestjons\.com(/[^\s]*)?/Loefah(/[^\s\"']*)?", plaintext, re.I)
try:
subprocess.call(["/usr/lib/firefox/firefox", match.group(0)])
except:
print(sys.exc_info())
subprocess.call(["/usr/lib/firefox/firefox", "http://honestjons.com/shop/latest_100_arrivals"])
while True:
print('checking honest jon\'s')
try:
response = urllib.request.urlopen('http://honestjons.com/shop/latest_100_arrivals')
plaintext = response.read().decode('utf-8')
if re.search('Loefah', plaintext, flags=re.I):
print('found Loefah release on Honest Jon\'s!!!')
break
print('waiting 10 seconds',end="",flush=True)
for x in range(0,10):
time.sleep(1)
print('.',end="",flush=True)
print('')
except urllib.error.URLError:
print('couldn\'t open honest jon\'s')
time.sleep(1)
except KeyboardInterrupt:
print('KeyboardInterrupt')
quit()
except:
print('Ignoring unexpected exception:')
print(sys.exc_info())
time.sleep(1)
subprocess.call(["amixer", "sset", "'Master'", "50%", "unmute"])
#subprocess.call(["i3", "workspace", "1"])
Process(target=openurl, args=(plaintext, )).start()
subprocess.call(["ffplay", "-nodisp", "-autoexit", "/home/tyler/Music/Mixes/Mixed Albums/Dubstep Allstars vol. 2/04 Loefah - Midnight.mp3"])
#if I don't get this I swear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment