Open brokkr opened 3 years ago
Leaving aside the question of attributes, YAML seems like an easy choice.
Example:
defaults:
metadata:
genre: podcast
settings:
base_dir: /mnt/media/
filenames: permissive
id3removev1: true
id3v2version: 3
useragent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0
subscriptions:
- filters:
title: natur
max_number: 2
metadata:
artist: Det:Er
rename:
- title
- episode_title
title: "Er h\xE5bet stadig gr\xF8nt?"
url: https://www.dr.dk/mu/feed/er-habet-stadig-groent.xml?format=podcast
- filters:
filename: CCEpSpecial
max_number: 2
title: The Crate and Crowbar
url: http://crateandcrowbar.com/category/episode/feed/
A few issues:
sortkeys=False
when dumping? (https://stackoverflow.com/a/64902048) but it doesn't seem to work ootb with safe_dump.allow_unicode=True
setting (https://stackoverflow.com/a/29600111) Also works for safe_dump (tested)Also: pathlib.Path (Python 3.4) for all Paths class operations
Note: using os.access on pathlike object (e.g. pahlib's Path class) requires 3.6
Still to do:
We can now save and read state.yaml including converting time_structs and pathlib.Paths back and forth. Still to do in addition to those mentioned above:
I believe either JSON or YAML would allow for significant code simpification (there's a lot of lines just parsing the XML). And I don't believe we really depend on the things that XML brings to the table (namespaces etc.)?
Advantages of JSON: Built-in (one less dependency), fast Advantages of YAML: Easy to read, supplanting pickle?
Really depends on how well either one deals with the heavily nested structure of say, a subscription with filters and metadata and renames... Also how would attributes translate?