Browse Source

Added the skeleton of a script to parse my ebook directory and pick one

master
Julio Biason 4 years ago
parent
commit
98ac6b8c45
  1. 23
      ebooks.py
  2. 2
      ebooks.xml
  3. 17742
      ebooks2.xml

23
ebooks.py

@ -0,0 +1,23 @@
import random
import xml.etree.ElementTree as ET
from urllib.parse import unquote
tree = ET.parse('ebooks2.xml')
root = tree.getroot()
favs = []
for response in root:
url = response.find('{DAV:}href').text
favorite = response.find('{DAV:}propstat')\
.find('{DAV:}prop')\
.find('{http://owncloud.org/ns}favorite').text
if favorite != '1':
continue
quoted = url.split('/')[-2]
name = unquote(quoted)
favs.append(name)
print(random.choice(favs))

2
ebooks.xml

File diff suppressed because one or more lines are too long

17742
ebooks2.xml

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save