refactoring #19

Closed
Barbagus wants to merge 4 commits from barbadev into stable
Collaborator

Getting lost trying to implement #11, I did do some helpfull (although, quasi-total) refactoring. I will push (probably not beofre Xmass) some of them over here for your consideration.

Getting lost trying to implement #11, I did do some helpfull (although, quasi-total) refactoring. I will push (probably not beofre Xmass) some of them over here for your consideration.
Enables by default:
- gzip compression
- request pooling
Lighter implementation and using `target_id` instead of `program_id`,
preparing for #7
A bunch of data structures to be used instead of the types used by the
infrastructures, i.e. JSON for API and M3U8 for the HLS.

It should provide a stronger decoupling of the modules and pave the way
for #7 and #8.

Implementation uses `namedtuple`s as they are transparent to test for
equality and are natively hashable (can be used in `set`s or as keys to
`dict`s) which is useful for deduping for instance.
- Rename variables and function to reflect model names.
- Convert infrastructure data (JSON, M3U8) to model types.
- Change algorithms to produce/consume `Source` model, in particular
  using generator functions to build a list of `Source`s rather than the
  opaque `rendition => variant => urls` mapping (this will make #7 very
  straight forward).

This was an extensive rewrite of the code base.
- move errors in a `error` module
- rename the module base error from `Error` to `ModuleError`
- fix some error handling in `__main__`
Author
Collaborator

Something important I failed to mention was done in ca0a792617 :

We use to offer rendition choosing right after the api call, before we download the appropriate master playlist to figure out the available variants.

The problem with that is that ArteTV's codes for the renditions (given by the api) do not necessarly include complete languages information (if it is not French or German), for instance a original audio track in portugese would show as VOEU- (as in "EUropean"). The actuall mention of the Portugese would only show up in the master playlist.

So, the new implementation actually downloads all master playlists straight after the api call. This is a bit wastefull, but I figured it was necessary to provide quality interaction with the user.

Bonus? Now when we first prompt the user for rendition choice, we actually already know the available variants available, maybe we make use of that fact in the future...

Something important I failed to mention was done in ca0a792617 : We use to offer _rendition_ choosing right after the `api` call, before we download the appropriate _master playlist_ to figure out the available _variants_. The problem with that is that ArteTV's _codes_ for the _renditions_ (given by the `api`) do not necessarly include complete languages information (if it is not French or German), for instance a original audio track in portugese would show as `VOEU-` (as in "EUropean"). The actuall mention of the Portugese would only show up in the _master playlist_. So, the new implementation actually downloads all _master playlists_ straight after the `api` call. This is a bit wastefull, but I figured it was necessary to provide quality interaction with the user. Bonus? Now when we first prompt the user for _rendition_ choice, we actually already know the available _variants_ available, maybe we make use of that fact in the future...
Author
Collaborator

Next step is to update/rewrite the README to reflect the changes... then I'll take the WIP off.

Next step is to update/rewrite the `README` to reflect the changes... then I'll take the `WIP` off.
Barbagus changed title from WIP: refactoring to refactoring 2022-12-28 10:00:02 +01:00
Barbagus closed this pull request 2022-12-29 08:58:08 +01:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
fcode/delarte!19
No description provided.