Thread: SoundKloud
View Single Post
Old 12-24-2012, 08:16 PM   #141
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Why the menus look horrible...

Why the menus look horrible...
Spoiler:


Quote:
It is important to make the distinction between what GTK+ controls and what the window manager controls. You are able to make recommendations and requests for the size and placement of top-level widgets. However, the window manager has ultimate control of these
features.
Conversely, you can use GTK_WINDOW_POPUP to create a pop-up window, although its name is somewhat misleading in GTK+. Pop-up windows are used for things that are not normally thought of as windows, such as tooltips and menus. Pop-up windows are ignored by the window manager, and therefore, they have no decorations or border frame.

There is no way to minimize or maximize a pop-up window, because the window manager does not know about them. Resize grips are not shown, and default key bindings will not work.

GTK_WINDOW_TOPLEVEL and GTK_WINDOW_POPUP are the only two elements available in the GtkWindowType enumeration. In most cases, you will want to use GTK_WINDOW_TOPLEVEL, unless there is a compelling reason not to.

Note You should not use GTK_WINDOW_POPUP if you only want window manager decorations turned off for the window. Instead, use gtk_window_set_decorated (GtkWindow *window, gboolean show) to turn off window decorations.


Code to start splatting stuff back into gtk into helpful pieces...
Spoiler:

Code:
#!python
# encoding: utf-8
# encoding declaration as specified here http://www.python.org/dev/peps/pep-0263/
import soundcloud
import subprocess 
import sys
import os
from time import sleep
import random
# create client object with app and user credentials
client = soundcloud.Client(client_id='8c882aabb8d9314021b236a291cd874c',
                           client_secret='blahbebalh')
                           
tracks = client.get('/tracks', q = sys.argv[1], limit=5,filter="streamable")
generator = random.Random()
i = 1
temp = {} #initalize dictionary

for track in tracks:
#  temptrk =  u'[{2}] Title: {0}\n ID: {1}'.format(track.title.encode('utf-8'), track.id, i) 
    
    titleage = track.title.encode('utf-8')

    tempy = titleage+'\n'

    temp.update({i:track.id}) #set dictionary key
    i=i + 1
  #  print tempy

#Let's just play the last one for now  

#return full list of links
for listing in range(1,i):
	queryb = listing
	trackid = temp.get(queryb) #retrieve key
	track = client.get('/tracks/{0}'.format(trackid))
	#tempart = "Artist: {0}\nDuration (in secs): {1}".format(track.user.get(u'username'), (track.duration/1000))
	temptitle= track.title.encode('utf-8')
	stream_url = client.get(track.stream_url, allow_redirects=False)
	
# this next bit actually gets returned.

	print "{0}¬{1} &".format(temptitle,stream_url.location)
#print "Track Loading complete"




Thoughts on delimiters. and why we have chosen ¬
Spoiler:
/*

DELIMS:

Excluded US-ASCII Characters disallowed within the URI syntax:

control = <US-ASCII coded characters 00-1F and 7F hexadecimal>
space = <US-ASCII coded character 20 hexadecimal>
delims = "<" | ">" | "#" | "%" | <">
unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","

for base64 the valid charset is:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx yz0123456789+/
the = is used as filler for the last bytes, as the length must be mulitple of 3

*/


Okay long story short - I got it all working again. but this time with no stupid lag or asynchrous menuing (well, so far) attached final pic of working playback menu.

next up.. searching.
Attached Thumbnails
Click image for larger version

Name:	TightVNC: kindle:0.0_092.png
Views:	213
Size:	35.3 KB
ID:	98261   Click image for larger version

Name:	TightVNC: kindle:0.0_094.png
Views:	186
Size:	31.2 KB
ID:	98263   Click image for larger version

Name:	TightVNC: kindle:0.0_095.png
Views:	186
Size:	31.6 KB
ID:	98265  

Last edited by twobob; 01-06-2013 at 10:25 PM.
twobob is offline   Reply With Quote