36 lines
1.1 KiB
Python
Executable File
36 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# 2025 dtb. public domain
|
|
import sys, xml.etree.ElementTree as ET
|
|
def f(fmt, e, t):
|
|
r = e.find(t, {
|
|
"": "http://www.w3.org/2005/Atom",
|
|
"media": "http://search.yahoo.com/mrss/",
|
|
"yt": "http://www.youtube.com/xml/schemas/2015"
|
|
})
|
|
return fmt % r.text if r is not None else ""
|
|
tree = ET.parse(sys.stdin)
|
|
root = tree.getroot()
|
|
ytid = f("%s", root, "yt:videoId")
|
|
print(
|
|
f("[%s] ", root, "published")
|
|
+ f("%s - ", root, "author/name")
|
|
+ f("%s", root, "title")
|
|
+ "\n\n"
|
|
+ f("%s", root, "media:group/media:description"),
|
|
end = "\n\n",
|
|
file = sys.stderr
|
|
)
|
|
print(
|
|
"#!/usr/bin/env menu" + "\n\n"
|
|
+ "Download feed." + "\n\n"
|
|
+ "\t" + "yt-dlp %s" % ytid + "\n\n"
|
|
+ "Print feed URL." + "\n\n"
|
|
+ "\t" + "printf 'https://youtube.com/watch?v=%%s\\n' '%s'" % ytid
|
|
+ "\n\n"
|
|
+ "Open feed URL in mpv." + "\n\n"
|
|
+ "\t" + "mpv" + " \\\n"
|
|
# + "\t\t" + "--script-opts=ytdl_hook-all_formats=yes" + " \\\n"
|
|
+ "\t\t" + "'https://youtube.com/watch?v=%s'" % ytid,
|
|
end = "\n\n"
|
|
)
|