Commit Graph

4193 Commits

Author SHA1 Message Date
bastimeyer 334e18e412 tools: add mypy config
- Add mypy and available typing stubs to dev-requirements
- Add mypy config
- Add py.typed to streamlink + streamlink_cli packages (PEP 561):
  This is required, so that mypy can import types from streamlink when
  installed in editable mode. Don't publish this file for now.
  Once various streamlink APIs are properly typed, typing stub files
  can be added instead.
2022-05-24 14:07:47 -07:00
bastimeyer 8fc178276e chore: fix import typing issues 2022-05-24 14:07:47 -07:00
bastimeyer ec93f520ac docs: enable intersphinx again
Change URL of requests' docs to requests.readthedocs.io
2022-05-23 15:20:50 -07:00
Ian Cameron d9ddc2f923 plugins.useetv: new plugin 2022-05-23 23:05:55 +02:00
bastimeyer db6252e3ec docs: temporarily disable intersphinx 2022-05-23 18:30:33 +02:00
bastimeyer 45f7369a64 tests: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer 3f508d1bed cli: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer 69b6f91eb8 plugins: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer 93262c870c stream.hls: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer 32fff15516 stream.dash: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer bb35232a60 logger: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer b50b27f859 options: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer dc548ab4b7 session: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer feb1534fa0 utils: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer 17697f0bc0 plugin.api: fix typing issues 2022-05-22 19:30:15 +02:00
bastimeyer c6b68b098b stream.hls_playlist: refactor M3U8Parser
- Generate a mapping of tags->callbacks on parser init once
  and cache mapping as class attribute (avoid parent class lookups)
- Performance: look up tags in cached mapping in `parse_line()`
- Re-order `parse_tag_...` methods by definition order of RFC 8216
- Add docstring to each `parse_tag_...` method with link to RFC 8216
- Add typing annotations to each `parse_tag_...` method
- Fix minor typing issues in regards to optional URIs in Key and Media
  and update parse methods accordingly
- Pass keywords to various named tuples instead of positional args
2022-05-22 18:04:34 +02:00
bastimeyer 473fda0a45 stream.hls: refactor segment decryption
- Catch ValueError when decrypting and unpadding segments, as well as
  other exceptions that can be raised when downloading the segment,
  similar to unencrypted segments, and log error messages accordingly.
  Don't close the stream on any of those errors.
- Remove garbage data truncation from encrypted segments:
  This was (most likely) implemented because of an old issue related to
  Content-Length HTTP headers not being handled correctly, leading to
  partial segment downloads. Cutting off data that doesn't fit into the
  AES block size doesn't make sense, as it implies that the segment data
  incomplete, and incomplete segment data misses its padding bytes at
  the end which must always be included.
- Update tests
2022-05-18 19:39:47 +02:00
Forrest 48d9886313
docs: clean up gravyboat donation links (#4534) 2022-05-18 08:46:06 +02:00
Ian Cameron 7591f29400 plugins.mildom: fix/update
* add auto update of HLS URL query string for auth
* refactor to use MildomAPI class
2022-05-17 07:22:45 +02:00
bastimeyer f08bc5a8ad docs: rewrite API guide
- Use unopinionated Apple HLS stream example URL
- Update Stream string representations
- Fix class/method/attribute references
2022-05-14 15:17:49 -07:00
bastimeyer 9e4a6577fa stream.hls: simplify discard logic in writer 2022-05-13 21:09:32 +02:00
bastimeyer ecb21f9781 stream: refactor to_url and string representation
- Change format of Stream string representations and error messages
  of `to_url` and `to_manifest_url`
- Don't override `__repr__` in `Stream` subclasses
- Raise TypeError if url or manifest URL is None
- Fix CLI
  - Abort passthrough if stream can't be translated to URL
  - Remove unneeded streamlink_cli.utils.stream module
- Rewrite stream URL tests
- Move FilmOnHLS stream URL tests to plugin test module (and rewrite)
2022-05-13 21:07:32 +02:00
bastimeyer 1a0074cc6c plugin.api.http_session: add prepare_new_request
- Move stream.http.valid_args to HTTPSession.valid_request_args
- Add HTTPSession.prepare_new_request
- Update HTTPStream
  - Use newly added HTTPSession methods
- Fix HLSStream
  - Prepare master URL appropriately
- Fix DASHStream
  - Return correct JSON data, depending whether manifest URL exists
  - Filter custom args in DASHStream.parse_manifest
- Use HTTPSession.prepare_new_request in plugins.twitch.UsherService
- Rewrite Stream JSON tests and move test module
2022-05-13 21:07:32 +02:00
bastimeyer d973cfc044 session: fix deprecated imports
- Import urllib3 directly instead of importing from requests.packages
- Remove unneeded urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST
  override, as it's not used on py3
- Update ipv4/ipv6 tests, add http-disable-dh tests
2022-05-12 10:52:09 -07:00
bastimeyer e2d9b36a82 http_session: don't disable InsecureRequestWarning 2022-05-12 10:51:53 -07:00
bastimeyer 810e0eb9b5 tests: move FileStream tests 2022-05-09 18:14:59 -07:00
Alexis Murzeau 081595cfed tests: mock user euid to be able to run tests as root
When running test as root, there is an additional log done to warn the
user that it is running streamlink as root. This causes some logging
tests to fail.

For these logging test, ensure we run with a mocked user euid when not
testing for the root euid.
2022-05-09 23:13:50 +02:00
Ian Cameron d9bd4518f7 plugins.crunchyroll: update/fix
* update params for Windows app
* remove Android headers
* fix device_id cached value
* add id to metadata
* minor spelling corrections
* add support for beta URLs
* update tests
* update cache.set() calls to use expires kw
* update expires_at=0 to expires=0
2022-05-08 09:26:27 +02:00
bastimeyer d09112ab1f plugin.api.validate: rewrite tests
Completely rewrite tests using pytest, with full coverage
2022-05-08 09:21:19 +02:00
bastimeyer 94ac8f63a3 plugin.api.validate: truncate error messages
- Change signature of `ValidationError` to be able to pass template
  strings and template variables which can get truncated individually.
- Make error messages consistent by using string representations for
  template variables where it makes sense
2022-05-08 09:21:19 +02:00
bastimeyer 3d44da082b plugin.api.validate: implement ValidationError
- Implement `ValidationError`
  - Inherit from `ValueError` to preserve backwards compatiblity
  - Allow collecting multiple errors (AnySchema)
  - Keep an error stack of parent `ValidationError`s or other exceptions
  - Format error stack when converting error to string
- Raise `ValidationError` instead of `ValueError`
  - Add error contexts where it makes sense
  - Add schema names to error instances
- Add and update tests
2022-05-08 09:21:19 +02:00
bastimeyer 120c103023 plugin.api.validate: turn module into package
Turn module into package with multiple logical sub-modules:
- Define a public interface in the package's `__init__` module
- Split validation schemas, validators and validate logic
  - schemas: classes which register attributes used by their
    respective `validate` implementations
  - validators: functions which can internally call `validate`
    and which return something that can be validated
  - validate: singledispatch functions which implement the validation
    logic for schemas and various other types
- Rename validation schemas for better internal references
- Rename singledispatch methods

Other clean-up work:
- Update comments and fix grammar
- Add type annotations
- Use f-strings
- Use `str` instead of the `text` alias
- Simplify some code blocks
- Rearrange classes and functions
- Rephrase certain error messages
- Add a few more tests for better code coverage
2022-05-08 09:21:19 +02:00
bastimeyer e0c37f6232 plugin.api.validate: refactor Schema class
Inherit from the all-schema directly to avoid having an unnecessary
singledispatch type definition.
2022-05-08 09:21:19 +02:00
bastimeyer 1008d56989 plugin.api.validate: fix xml_element
Add missing tail attribute and clone child nodes
2022-05-08 09:21:19 +02:00
bastimeyer c5639c3f6c plugin.api.validate: refactor callable
Remove callable check from the base validate singledispatch function
and register the abc.Callable type instead.

Also fix type validation in the transform schema.
2022-05-08 09:21:19 +02:00
bastimeyer f23870caeb plugin.api.validate: refactor get
Turn into validation schema with a singledispatch function.
This is required for the upcoming module split.
2022-05-08 09:21:19 +02:00
bastimeyer 1b071b8747 plugin.api.validate: refactor all + any
Turn into SchemaContainer subclasses
2022-05-08 09:21:19 +02:00
yhhsin 402645b620
stream.segmented: join worker+writer on close (#4517)
Co-authored-by: bastimeyer <mail@bastimeyer.de>
2022-05-08 04:21:30 +02:00
bastimeyer bcd624c175 ci: use GITHUB_TOKEN for deploying to GitHub 2022-05-07 12:20:56 +02:00
bastimeyer b77cf7883e script: rename github release script 2022-05-07 12:20:56 +02:00
bastimeyer 5249900b3e script: rewrite github release script
- Completely rewrite GitHub release script
  - Remove --dry-run and make it implicit when no API key is set
  - Remove --api-key and read from RELEASES_API_KEY or GITHUB_TOKEN
  - Add --template, --changelog, --no-contributors and --no-shortlog
  - Refactor GitHub API stuff
  - Update release template logic and use Jinja2
  - Get list of contributors (with support for commit co-authors):
    GitHub highlights usernames in releases, which this is meant for
  - Generate git shortlog automatically
  - Always close open file handles
- Update release template based on Jinja2 logic
- Update release CI job
  - Install Jinja2
  - Upgrade Python to 3.10 and setup-python to v2
  - Fetch entire repo
  - Don't upload wheels to GitHub releases
2022-05-07 12:20:56 +02:00
bastimeyer a99eae15f2 changelog: remove git shortlogs 2022-05-07 12:20:56 +02:00
bastimeyer ef36240408 plugins.youtube: fix consent dialog 2022-05-05 20:09:55 +02:00
Ian Cameron e8c7e0ff7e plugins.hiplayer: new plugin
* replaces rotana with rewrite/fix
* add support for cnbcarabia.com, media.gov.kw
2022-05-02 21:19:51 +02:00
Ian Cameron e5cdbd2dec plugins.rotana: plugin removal 2022-05-02 21:19:21 +02:00
bastimeyer 867b9b3b66 docs: use cross-reference instead of direct link 2022-05-01 21:24:28 -07:00
bastimeyer 3cf149f0c1 docs: update dependencies section in install docs 2022-05-01 21:24:20 -07:00
Ian Cameron 133e58bd1f
Merge pull request #4506 from sknebel/patch-2
docs: fix broken relative link
2022-05-01 23:58:52 +01:00
Sven 3a3d2fb6d5
docs: fix broken relative link 2022-05-02 00:21:46 +02:00
bastimeyer e7821a2428 release: 4.0.1 2022-05-01 19:37:57 +02:00