Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3815934
D1654.id4224.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D1654.id4224.diff
View Options
diff --git a/roles/devserver/userland-home/files/dereckson/bin/http2pls b/roles/devserver/userland-home/files/dereckson/bin/http2pls
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/http2pls
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+
+from bs4 import BeautifulSoup
+from urllib import request, parse
+from os import path
+from sys import argv, exit
+
+
+def get_url (base_url, tag):
+ relative_url = tag.get('href')
+ return parse.urljoin(base_url, relative_url)
+
+
+def is_media_extension(extension):
+ valid_extensions = [
+ # Videos
+ ".avi", ".flv", ".mp4", ".wmv"
+ ]
+ return extension in valid_extensions
+
+
+def is_media_link(url):
+ extension = path.splitext(url)[1]
+ return is_media_extension(extension)
+
+
+def generate_pls (url):
+ print("[playlist]")
+
+ i = 0
+ for link in get_media_links(url):
+ i += 1
+ print('File{:d}={:s}'.format(i, link))
+
+ print("")
+ print("NumberOfEntries={:d}".format(i))
+ print("Version=2")
+
+def get_media_links (url):
+ return [link for link in get_links (url) if is_media_link(link)]
+
+
+def get_links (url):
+ with request.urlopen(url) as response:
+ body = response.read()
+
+ soup = BeautifulSoup(body, 'html.parser')
+ return [get_url(url, link) for link in soup.find_all('a')]
+
+def run ():
+ if len(argv) < 2:
+ exit(1)
+
+ generate_pls(argv[1])
+
+if __name__ == "__main__":
+ run()
diff --git a/roles/devserver/userland-software/dev.sls b/roles/devserver/userland-software/dev.sls
--- a/roles/devserver/userland-software/dev.sls
+++ b/roles/devserver/userland-software/dev.sls
@@ -83,6 +83,10 @@
pkg:
- installed
- pkgs:
+ # Modern Python 3 packages
+ - {{ packages_prefixes.python3 }}beautifulsoup
+
+ # Legacy packages
- {{ packages_prefixes.python2 }}nltk
- {{ packages_prefixes.python2 }}numpy
- {{ packages_prefixes.python2 }}virtualenv
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 04:40 (21 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2276977
Default Alt Text
D1654.id4224.diff (1 KB)
Attached To
Mode
D1654: Deploy for dereckson a playlist generator script on devserver
Attached
Detach File
Event Timeline
Log In to Comment