-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapt-play
More file actions
executable file
·36 lines (28 loc) · 837 Bytes
/
apt-play
File metadata and controls
executable file
·36 lines (28 loc) · 837 Bytes
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
#!/usr/bin/python
import requests
import urllib
import os
import sys
def get_youtube(package):
index_url = "https://www.youtube.com/results?search_query=" + package + "linux"
response = requests.get(index_url)
body = (response.text)
videos = []
lines = body.split(">")
for line in lines:
if "/watch?v=" in line:
tmp = line
tmp = tmp[:tmp.index("\" ")]
tmp = tmp[tmp.index("=")+2:]
if "/watch?v=" in tmp:
link = 'https://youtube.com' + tmp
videos.append(link)
return videos
#print(body)
if len(sys.argv) < 2:
print('Invalid input, apt-play [package]')
exit(0)
package = sys.argv[1]
videos = get_youtube(package)
#os.system("vlc " + videos[0])
os.system("mpv --really-quiet '" + videos[0] + "'")