-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandup.py
More file actions
80 lines (63 loc) · 1.74 KB
/
standup.py
File metadata and controls
80 lines (63 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""
Standup Module to Play a song
Setup:
Install python-pip, pyglet python library and avbin library.
on Ubuntu:
sudo apt-get install pyhton python-pip
sudo pip install pyglet
sudo apt-get install libavbin-dev libavbin0
sudo pip install --upgrade youtube_dl
sudo apt-get install libavcodec-extra-53
"""
import pyglet
import youtube_dl
import sys
import cherrypy
# Bob Marley -- Get up, stand up .. stand up for your rights..
if len(sys.argv) <= 1:
yt_urls = ["https://www.youtube.com/watch?v=X2W3aG8uizA"]
else:
yt_urls = sys.argv[1:]
yt_videos = []
def get_yt_video(yt_url):
"""Download a youtube video and convert it to mp3"""
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'outtmpl': '%(id)s.%(ext)s'
}
ydl = youtube_dl.YoutubeDL(ydl_opts)
with ydl:
result = ydl.extract_info(
#'http://www.youtube.com/watch?v=BaW_jenozKc',
yt_url,
download=True # We just want to extract the info
)
if 'entries' in result:
# Can be a playlist or a list of videos
video = result['entries'][0]
else:
# Just a video
video = result
return video
## Debug video object:
#for key in video:
# print("key: %s value: %s" % (key,video[key]))
# get all videos
#for yt_url in yt_urls:
# yt_videos.append(get_yt_video(yt_url))
# play first one
#music = pyglet.resource.media(yt_videos[0]['display_id'] + '.mp3')
#music.play()
#print('Start Pyglet App')
#pyglet.app.run()
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.server.socket_host = '0.0.0.0'
cherrypy.quickstart(HelloWorld())