Skip to content

Instantly share code, notes, and snippets.

@vmlemon
Created January 4, 2014 23:47
Show Gist options
  • Save vmlemon/8262380 to your computer and use it in GitHub Desktop.
Save vmlemon/8262380 to your computer and use it in GitHub Desktop.
A broken, experimental "port" of Kashiru.py to Python 3.
#!/usr/bin/python
#from bs4 import BeautifulSoup #sudo easy_install beautifulsoup4
import sys
#Download CURL from http://www.confusedbycode.com/curl/, to use under Windows... (Tested with 64-bit version + Python 3.3.3 + Win8)
#If using the HTML slugs generated by this script in Chrome, please add this somewhere to the HTML file:
#<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
#print "Kashiru...\n\n"
#We can obtain a JavaScript lyrics dump consisting of a document.write() statement consisting of HTML from http://www.kasi-time.com/item_js.php?no=42415
#Substitute the number appropriately...
iHtmlEncPrelude = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
iTrackNum = "67686" #ikanaide ...
#http://www.tutorialspoint.com/python/python_command_line_arguments.htm
#Do something if we've got a different track number...
if len(sys.argv) != 1:
iTrackNum = str(sys.argv[1])
else:
iTrackNum = "67686" #ikanaide ...
iParentUri = "http://www.kasi-time.com/item_js.php?no=" #Probably subject to change
#http://stackoverflow.com/questions/2711579/concatenate-strings-in-python-2-4
iFullTrackUri =''.join([iParentUri, iTrackNum])
import subprocess ##Silence is golden...
iTrackHtml = subprocess.check_output("curl" + " -s " + iFullTrackUri).strip()[:-3] #Monkey don't like quotes, and brackets
#Bye-bye, "document.write('"
iJsFreeHtml = iTrackHtml[16:]
iEncStr = iHtmlEncPrelude + str(iJsFreeHtml )
#print(WORDS)
print(iEncStr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment