refactoring #21

Merged
Barbagus merged 8 commits from barbadev2 into stable 2022-12-29 07:58:48 +00:00
Collaborator

New PR #19 with modified commit messages.

New PR #19 with modified commit messages.
Barbagus added 8 commits 2022-12-29 07:56:31 +00:00
88ffe31a94 Use `requests` library instead of `urllib`
Enables by default:
- gzip compression
- request pooling
4c518993ef Change error handling
Creation of a `common.Error` exception whose string representation is
taken from its docstring.

Creation of a `common.UnexpectedError` to serve as base for exceptions
raised while checking assumptions on requests and responses.

The later are handled by displaying a message inviting user to submit
the error to us, so we can correct our assumptions.
305d8ab679 Refactor website URL parsing
Lighter implementation and using `target_id` instead of `program_id`,
preparing for #7
4fa5e1953e Create the data model types
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.
db0a954497 Refactor code to use the model types
- 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).
- Download all master playlists after API call before selecting
  rendition/variants.

Motivation for the last point:

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 necessarily include complete languages information
(if it is not French or German), for instance a original audio track in
Portuguese would show as `VOEU-` (as in "EUropean"). The actual mention
of the Portuguese 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 wasteful, 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...
07ef013ce3 Rename error handling
- move errors in a `error` module
- rename the module base error from `Error` to `ModuleError`
- fix some error handling in `__main__`
Barbagus changed title from WIP: refactoring to refactoring 2022-12-29 07:56:46 +00:00
Barbagus merged commit 3ec2961a85 into stable 2022-12-29 07:58:48 +00:00
Barbagus deleted branch barbadev2 2022-12-29 07:58:48 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
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#21
No description provided.