Initial commit
This commit is contained in:
22
examples/ytfeed.browse-feeds
Executable file
22
examples/ytfeed.browse-feeds
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# 2025 dtb. public domain
|
||||
import os, sys, xml.etree.ElementTree as ET
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: %s directory\n" % sys.argv[0], file = sys.stderr)
|
||||
sys.exit(64) # sysexits(3) EX_USAGE
|
||||
channels = []
|
||||
directory = sys.argv[1]
|
||||
for f in os.listdir(directory):
|
||||
file_name = os.path.join(directory, f)
|
||||
if os.path.isfile(file_name) and f[-4:] == ".xml":
|
||||
tree = ET.parse(file_name)
|
||||
root = tree.getroot()
|
||||
try:
|
||||
channels += [
|
||||
"%s\n\n" % root.find('{http://www.w3.org/2005/Atom}title').text
|
||||
+ "\t<'%s' ytfeed.browse-feed | ../menu\n\n" % file_name
|
||||
]
|
||||
except: pass
|
||||
print("#!/usr/bin/env menu", end = "\n\n")
|
||||
for s in sorted(channels, key=str.lower): # Sorts alphabetically (caseless).
|
||||
print(s, end = "")
|
||||
Reference in New Issue
Block a user