Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit, can't get cookies out

  • Loading branch information...
commit 4a4b13de9a792f80cdf861baebadfb652857deaf 0 parents
@ngokevin authored
Showing with 39 additions and 0 deletions.
  1. +39 −0 soundcloud.py
39 soundcloud.py
@@ -0,0 +1,39 @@
+from optparse import OptionParser
+import mechanize
+import re
+
+def open_page(url):
+ return mechanize.urlopen(url)
+
+def get_stream_token_uid(page):
+ """ returns stream token and uid as tuple """
+ match = re.search('"uid":"([\w\d]+?)".*?stream_token=([\w\d]+)', page)
+ if match:
+ uid = match.group(1)
+ stream_token = match.group(2)
+ return (uid, stream_token)
+
+if __name__ == '__main__':
+
+ parser = OptionParser()
+ parser.add_option("-u", "--url")
+ (options, args) = parser.parse_args()
+
+ cj = mechanize.LWPCookieJar()
+ opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies))
+ mechanize.install_opener(opener)
+
+ browser = mechanize.Browser(factory=mechanize.RobustFactory())
+ browser.open(options.url)
+ html = browser.response().get_data()
+
+ # HOW GET COOKIE?
+
+ #page = open_page(options.url).read()
+ #(uid, stream_token) = get_stream_token_uid(page)
+
+ #url = "http://media.soundcloud.com/stream/%s?stream_token=%s" % (uid, stream_token)
+
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.