Archive for May, 2012
kv language designing with anchorlayout
0When designing a Kivy menu with the kv language I run into troubles with the anchorlayout object.
It seems that you need to put every object inside a achorlayout which itself is part of a anchorlayout.
Sounds a bit vague so an example should do:
[sourcecode language=”text”]
<topbox>:
AnchorLayout:
id: topmenu
anchor_x: ‘center’
anchor_y: ‘top’
BoxLayout:
orientation: ‘horizontal’
AnchorLayout:
anchor_x: ‘left’
anchor_y: ‘top’
padding: 8
Button:
id: infobutton
size: (48, 48)
size_hint: None, None
background_normal: ‘info_button.png’
background_down: ‘info_button.png’
on_press: root.on_button_clicked("info")
AnchorLayout:
anchor_x: ‘center’
anchor_y: ‘top’
padding: 8
BoxLayout:
padding: 0
spacing: 4
size: (300, 48)
size_hint: None, None
orientation: ‘horizontal’
AnchorLayout:
anchor_x: ‘center’
anchor_y: ‘top’
Button:
size: (48, 48)
size_hint: None, None
background_normal: ‘star1.png’
on_press: root.on_button_clicked("star1")
AnchorLayout:
anchor_x: ‘center’
anchor_y: ‘top’
Button:
size: (48, 48)
size_hint: None, None
background_normal: ‘star1.png’
on_press: root.on_button_clicked("star2")
AnchorLayout:
anchor_x: ‘right’
anchor_y: ‘top’
padding: 8
Button:
id: quitbutton
size: (48, 48)
size_hint: None, None
background_normal: ‘quit_button.png’
background_down: ‘quit_button_ro.png’
on_press: root.on_quit_button_clicked()
[/sourcecode]
youtube_pl2vids.py
0Python script to download youtube vids
[sourcecode language=”python”]
import sys, os, random, time
if len(sys.argv) < 3:
print "Usage: youtube_pl2vids [playlist.html] [destination directory]"
sys.exit(1)
source = sys.argv[1]
dest = sys.argv[2]
urllines = []
f = open(os.path.join(dest, ‘youtube.dl’), ‘w’)
for line in open(source, ‘r’).readlines():
if ‘<a href="/watch?v=’ in line and ‘class="tile-link-block video-tile"’ in line:
url = "http://www.youtube.com" + line.split(‘&’)[0].split(‘<a href="’)[1]
f.write(url + ‘n’)
urllines.append(url)
f.close()
print urllines
# we assume youtube-dl is installed
for line in urllines:
os.system(‘youtube-dl -t –max-quality 22 %s’ % line)
s = random.randint(1, 6)
print "sleeping %s secs" % s
time.sleep(s)
[/sourcecode]
Download youtube videos from your playlist
0Create a playlist in your youtube account.
Download the playlist page and save it as html.
Install youtube-dl: sudo apt-get install youtube-dl
Start youtube_pl2vids.py script with the path of the playlist.html.
For example: python youtube_pl2m3u.py playlist.html vidsdirectory
Your videos will be downloaded and placed in the ‘vidsdirectory’
The script will sleep for some random seconds between downloading the vids to simulate human interaction.
First post
0This will become the onlineĀ place where I can keep my stuff.
Recent Comments