brokkr / poca

A fast, multithreaded and highly customizable command line podcast client, written in Python 3
GNU General Public License v3.0
23 stars 4 forks source link

Switching to YAML for config #128

Open brokkr opened 3 years ago

brokkr commented 3 years ago

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?

brokkr commented 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:

brokkr commented 3 years ago

Also: pathlib.Path (Python 3.4) for all Paths class operations

brokkr commented 3 years ago

Note: using os.access on pathlike object (e.g. pahlib's Path class) requires 3.6

brokkr commented 3 years ago

Still to do:

brokkr commented 3 years ago

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: