1
mirror of https://github.com/streamlink/streamlink synced 2024-11-01 01:19:33 +01:00
Commit Graph

3238 Commits

Author SHA1 Message Date
bastimeyer
d33df662a4 stream.dash: turn Segment into dataclass
and rename `range` attribute to `byterange` (similar to HLS Segment)
2023-02-21 10:57:05 -08:00
bastimeyer
fe6c0183f5 stream.dash: rename constants 2023-02-21 10:57:05 -08:00
bastimeyer
6597054331 stream.dash: fix def param in count_dt() generator 2023-02-21 10:57:05 -08:00
bastimeyer
9d813c5b69 stream.dash: replace isodate UTC with stdlib impl 2023-02-21 10:57:05 -08:00
bastimeyer
85ea235d13 chore: add "A" rules to ruff config 2023-02-20 14:10:06 -08:00
bastimeyer
ba78ad2ec3 chore: add "PIE" rules to ruff config 2023-02-20 14:10:06 -08:00
bastimeyer
9cfe62d03c chore: add "PL{C,E,W}" rules to ruff config 2023-02-20 14:10:06 -08:00
bastimeyer
f5d2828a08 session: fix minor mistakes in options docstring 2023-02-17 19:17:34 +01:00
bastimeyer
74e0f7a99d session: fix http-query-params string delimiter 2023-02-17 09:54:35 -08:00
bastimeyer
94e14e6724 session: fix options docstring
- Fix default options
  - Reorder according to cli argparse mapping
  - Add missing defaults (except deprecated keys)
  - Fix incorrect defaults
- Fix set_option() docstring
  - Replace rst table with list-table from myst-parser extension
  - Reformat table and add key, type, default and description columns
  - Add all missing keys, including deprecated keys
  - Reorder keys according to default keys
  - Fix types and update descriptions
- Add docstring tests
2023-02-17 09:54:35 -08:00
bastimeyer
151a8d7dbc options: add some MutableMapping methods 2023-02-17 09:54:35 -08:00
bastimeyer
0696f48593 stream.ffmpegmux: refactor errorlog fd
- Change priority of --ffmpeg-verbose-path and --ffmpeg-verbose
- Remove unneeded subprocess.DEVNULL compatibility export
- Suppress OSError when closing fd of --ffmpeg-verbose-path
- Update tests
2023-02-15 10:12:27 -08:00
bastimeyer
498efd523c utils.named_pipe: fix fifo unlink race condition 2023-02-14 12:47:36 -08:00
bastimeyer
546386208c stream.ffmpegmux: fix copy-to-pipe race condition
Make sure that each substream's buffer always gets fully emptied
when closing the stream, so that no data is missing when muxing
the output stream.

TODO: properly refactor FFMPEGMuxer class with full test coverage
2023-02-14 12:47:36 -08:00
bastimeyer
76480b0dec stream.hls: fix parse_hex warning message 2023-02-14 10:42:24 -08:00
bastimeyer
13915cf86d chore: fix issues introduced by ruff 0.0.245 2023-02-11 12:45:05 +01:00
bastimeyer
4622c9728e chore: add "ISC" rules to ruff config 2023-02-09 11:48:40 -08:00
bastimeyer
17daf563a3 chore: add "C4" rules to ruff config 2023-02-09 11:48:40 -08:00
bastimeyer
57fa6f80e8 chore: add "COM" rules to ruff config 2023-02-09 10:26:50 -08:00
bastimeyer
9fd14e3f9d chore: add "Q" rules to ruff config 2023-02-09 10:26:50 -08:00
bastimeyer
faab9200c7 chore: add "I" and "TID" rules to ruff config 2023-02-09 10:26:50 -08:00
TaoziDB
ce2c5e11db
plugins.nimotv: fix livestream stopping after couple of seconds (#5147) 2023-02-08 16:12:13 +01:00
bastimeyer
3094941958 plugins.youtube: restore /user/... URLs 2023-02-08 14:59:26 +00:00
bastimeyer
04da9f5cdc stream.hls: refactor various attribute parsers
- Turn methods into classmethods
- Emit warning messages on parsing failure
- Add unit tests
2023-02-07 09:58:03 +01:00
bastimeyer
3e83393811 stream.hls: refactor and fix attribute list parser
- Rewrite and fix attribute list regex
- Be more strict when parsing multiple attributes and expect the
  mandatory comma separator, but be lenient about spaces surrounding
  attributes (off-spec), similar to the old implementation
- Add missing support for signed decimal floating point numbers
- Fix invalid range of hexadecimal sequences and allow uppercase prefix
- Fix character range of enumerated strings being too narrow
- Fix character range of quoted strings
- Discard entire attribute list on parsing failure and emit warning
- Add unit tests
2023-02-07 09:58:03 +01:00
bastimeyer
9fa2d820a5 plugins.youtube: rewrite and fix matchers 2023-02-06 22:41:17 +01:00
bastimeyer
319a60f54f plugins.youtube: fix adaptive streams KeyError 2023-02-03 10:23:14 -08:00
bastimeyer
0589750c8f options: deprecate global plugin arguments
- Raise `StreamlinkDeprecationWarning` when `is_global=True`
- Remove all global plugin arguments and replace them with simple
  option lookups on the Streamlink session instance
- Remove global argument detection in custom Sphinx plugins extension
- Remove supported plugins list from custom Sphinx argparse extension
  and remove respective setup from `setup_plugin_args` in the CLI module
- Add deprecation note to the docs
- Update tests
  - Check whether builtin plugins define global plugin arguments
  - Capture deprecation warnings
2023-02-03 10:21:31 -08:00
streamlinkbot
fbb9ed6497 plugin.api: update useragents 2023-02-01 00:22:42 +00:00
bastimeyer
4b82f1f595 docs: improve loglevel help text 2023-01-30 16:17:49 +00:00
back-to
39dd8f898e plugins.funimationnow: deleted 2023-01-29 11:31:36 +01:00
back-to
25c04a6b26 plugins.schoolism: deleted 2023-01-29 11:26:42 +01:00
bastimeyer
5340477207 stream.hls: warn when writing after discontinuity 2023-01-23 04:42:08 +01:00
Ian Cameron
e629975e71
plugins.earthcam: fix cam_name (#5110)
Co-authored-by: HappyPlotter <111639418+happyplotter@users.noreply.github.com>
2023-01-22 11:12:59 +01:00
Ian Cameron
90c1860580 plugins.tvp: add tvp.info 2023-01-20 21:55:53 +01:00
bastimeyer
91bf178e38 plugins.orf_tvthek: remove
Both HLS and DASH live streams are protected by DRM, which makes
a plugin rewrite and cleanup impossible.
2023-01-20 13:14:57 +00:00
bastimeyer
0c8375beb4 plugin: add support for named plugin matchers 2023-01-19 18:41:38 -08:00
Ian Cameron
fe6f51aa75 plugins.ceskatelevize: update for ct24, sport and sportplus; add decko 2023-01-19 20:03:06 +01:00
bastimeyer
c3f942beff chore: remove unneeded noinspection directives 2023-01-18 08:01:52 +01:00
Ian Cameron
7484f76a97 plugins.mixcloud: new plugin 2023-01-18 07:29:53 +01:00
bastimeyer
fe9be00832 chore: ignore coverage in TYPE_CHECKING blocks 2023-01-14 07:47:08 +01:00
bastimeyer
c211e5866e plugin.api.validate: deprecate text alias
- Deprecate text alias and raise StreamlinkDeprecationWarning on access
- Add deprecation to docs
- Replace validate.text with str in remaining plugins
- Update test
2023-01-13 11:27:11 -08:00
bastimeyer
777d1be3de logger: add StreamlinkWarning
- Add `StreamlinkWarning` and `StreamlinkDeprecationWarning`
  and replace `FutureWarning`s
- Don't include the warning's origin in the warning logger if it's a
  subclass of `StreamlinkWarning`
- Update tests
2023-01-12 15:54:18 -08:00
bastimeyer
d5b2981fbe logger: turn deprecation log msgs into warnings
- Replace all deprecation warning log messages with `FutureWarning`s
- Fix deprecated session options in tests
- Update and fix tests
2023-01-12 15:54:18 -08:00
bastimeyer
a76cefe7ca logger: capture warnings
Add support for capturing warnings and logging them via Streamlink's
root logger on the warning log level. Use custom `WarningLogRecord`s
with a custom warning message format, and replace the record's
logger name with "warnings" and use the name of the warning type
as log level name when showing warnings.

This enables having proper `DeprecationWarning`s and `FutureWarning`s
in the code instead of just using the logger and its warning log level,
and those warnings can be filtered via the regular filtering mechanisms.

For example:
```
[warnings][deprecationwarning] Calling this method is deprecated
[warnings][futurewarning] Using this config file path is deprecated
```
2023-01-12 15:54:18 -08:00
bastimeyer
6556276940 exceptions: remove url arg from NoStreamsError 2023-01-12 09:49:02 -08:00
bastimeyer
109263b186 exceptions: update docs and fix NoPluginError
- Make `NoPluginError` inherit from `StreamlinkError`
  instead of `PluginError`
- Update and fix docstrings of all Streamlink exception classes
- Update list of exceptions in API docs
- Fix exports
2023-01-12 09:49:02 -08:00
bastimeyer
ae75834736 plugins.euronews: fix and rewrite plugin 2023-01-10 13:59:00 +01:00
bastimeyer
5e3719f1f9 session: refactor option getter+setter methods
Replace the logic of the `Streamlink.{get,set}_option()` methods with
a new `StreamlinkOptions` subclass which uses mapped option
getters+setters that apply the custom option logic instead.

This improves the runtime of said methods, as option mappers are
looked up in Python dictionaries in constant time, so option names
don't have to be checked one after another.

Also add deprecation messages when
- getting the deprecated `https-proxy` option
- setting the deprecated `{hls,dash}-segment-attempts` options
- setting the deprecated `{hls,dash}-segment-threads` options
- setting the deprecated `{hls,dash}-segment-timeout` options
- setting the deprecated `{hls,dash,http-stream}-timeout` options
2023-01-07 18:04:38 -08:00
bastimeyer
41c6fa197e options: add support for mapped getters+setters 2023-01-07 18:04:38 -08:00
bastimeyer
355179cecc options: refactor key normalization
- Store key names with dashes instead of underscore characters.
  This makes it consistent with the default Streamlink session options.
- Add typing information
2023-01-07 18:04:38 -08:00
bastimeyer
b1c6d8bffa cli: replace read_stream() with StreamRunner
Replace `read_stream()` with a new `StreamRunner` class, refactor stream
reads and output writes, as well as the progress thread data feeding,
and move player polling into a separate thread which closes the stream
once the player process gets terminated/killed.

This fixes the player polling issue, or rather the detection of its
broken pipe while reading the stream, as stream read calls can stall
for various reasons, e.g. due to segmented streams or the filtering
of stream data which pauses the stream output and disables any timeouts.

- Implement `StreamRunner` and `PlayerPollThread` classes
  in dedicated `streamlink_cli.streamrunner` module
- Remove old `streamlink_cli.main.read_stream()` implementation
- Keep the same log messages
- Make `StreamRunner.run()` raise `OSError` on read/write error and
  catch `OSError`s in main module where `console.exit()` gets called
- Remove `Progress.iter()`, as it's not needed anymore
- Add extensive tests with full code coverage
2023-01-01 10:07:37 +01:00
bastimeyer
d4e056b63c cli: refactor progress interface
Rename `Progress.put()` to `Progress.write()`, to make it consistent
with other output related interfaces:
`PlayerOutput`, `FileOutput` and `HTTPServer`
2023-01-01 10:07:37 +01:00
streamlinkbot
e2c8e46018 plugin.api: update useragents 2023-01-01 01:24:23 +01:00
bastimeyer
578467b131 2023 2023-01-01 01:23:38 +01:00
bastimeyer
d695e40e52 plugins.dogan: rewrite and fix plugin
- Update and split up URL matchers
- Use XPath for finding content IDs
- Fix and update API URLs and validation schemas
- Remove nesting and simplify
2022-12-30 16:59:05 +01:00
Inokenty
d8225bbbff
plugins.vkplay: new plugin (#5054)
Co-authored-by: bastimeyer <mail@bastimeyer.de>
2022-12-29 19:16:25 +01:00
bastimeyer
9216177773 tests: refactor websocket tests
- Switch to pytest
- Replace custom thread Events with thread handshakes
2022-12-28 11:24:15 -08:00
bastimeyer
716e24d109 cache: refactor Cache and rewrite tests
- Turn filename into a Path and accept "pathlike" values
- Fix file handle not being closed on error when serializing data
- Add typing information
- Add TO-DO comments
- Rewrite tests
  - Switch to pytest
  - Use pytests's tmp_path fixture instead of custom temp path stuff
  - Properly freeze time during expiration tests
2022-12-26 11:12:23 -08:00
Ian Cameron
10c4246bb4 plugins.cdnbg: update regex 2022-12-20 11:10:22 +01:00
bastimeyer
5639a065bf tests: refactor and add more buffer tests
- Rename test file to match module file name
- Switch to pytest
- Add more strict assertions to existing tests
- Add more basic tests and new tests for threaded read/write calls of
  the `RingBuffer` for full code coverage
2022-12-18 12:03:51 -08:00
Ian Cameron
c8a707e7a9 plugins.vtvgo: update headers 2022-12-13 01:17:21 +01:00
fenopa
68dad1059f
plugins.turkuvaz: fix url match (#5021) 2022-12-11 20:29:59 +01:00
bastimeyer
3151175bcd plugins.twitch: better access token error handling
- Refactor `TwitchAPI` class:
  - Set `CLIENT_ID` as a class attribute (for test references)
  - Allow `call()` to pass custom headers (currently unused)
  - Remove unneeded `json.dumps()`
- Handle `PlaybackAccessToken` error response and log error messages
- Add `Options.clear()` for resetting plugin options state after tests
- Add access token API tests
2022-12-04 10:56:22 +01:00
bastimeyer
b9f3295658 plugins.twitch: fix ad filtering bug
Twitch doesn't include duration data for prefetch segments, which means
when more than one prefetch segment is included in the HLS playlist,
the start time of the second (or third) prefetch segment has to be
guessed from the duration of the regular segments. This is done by
calculating the average of all available regular segments and using that
as an offset of the last regular segment for each prefetch segment.

This however can cause issues when segment durations vary a lot and the
start time of an annotated ad block doesn't match the extrapolated start
time of the first ad segment due to the miscalculation. The ad segment
then gets incorrectly included in the output stream.

Since a discontinuity tag is always present, even between prefetch tags
with ads, we can make use of it and treat prefetch segments after a
discontinuity tag as ads. This won't cause any issues during the
transition to the regular stream content, as it only affects the logic
of prefetch segments.
2022-12-03 00:14:22 +01:00
streamlinkbot
471f9efeb8 plugin.api: update useragents 2022-12-01 02:11:08 +01:00
bastimeyer
55b585288b plugins.svtplay: rewrite plugin and add HLS 2022-11-28 20:45:56 +00:00
bastimeyer
32d8ff448a stream.ffmpegmux: abort on ValueError during read 2022-11-26 11:27:19 +01:00
bastimeyer
f51bff07f3 plugins.tvp: fix channel ID lookup
- Fix channel ID lookup
- Fix validation schema on missing data
- Add more stream types to live streams: HTTPStream for content
  restriction clips, and DASHStream where HLS is not available
- Apply minor code refactoring
2022-11-24 18:08:55 +01:00
bastimeyer
3d4ebf341b plugin.api.websocket: use certifi's cacert.pem
- Add `certifi` as a direct dependency (already defined by `requests`)
  and don't set a version range
- Set the `ca_certs` SSL option in `WebsocketClient` which defaults to
  the CA certs file bundled by `certifi`, similar to HTTPS requests
  made by `requests`
2022-11-17 09:57:08 -08:00
bastimeyer
28fd94df49 stream: add FilteredStream and abstract filtering 2022-11-16 16:08:54 -08:00
bastimeyer
485a5b54b4 stream.segmented: properly close StreamIO 2022-11-15 18:22:34 -08:00
fenopa
3ccdb957d3 plugins.tv8: filter out ad segments 2022-11-13 23:21:38 +01:00
bastimeyer
3d02f6c9cd cli: fix log format for log level "all" 2022-11-13 20:30:39 +01:00
bastimeyer
8105bfcf32 plugins.twitch: add segment ad detection fallback 2022-11-12 20:17:50 +01:00
bastimeyer
14ffbb0b83 plugins.twitch: fix date offset of prefetch ads 2022-11-12 20:17:50 +01:00
bastimeyer
5667cb8197 plugins.twitch: improve plugin notes and arg texts 2022-11-12 13:42:11 +01:00
bastimeyer
721f732b82 stream.hls: log HLS playlist content while parsing 2022-11-12 13:38:47 +01:00
bastimeyer
0318a0080d logger: implement StreamlinkLogger.iter()
And fix minor issues from 2bf6ee45:
- add missing ALL export
- remove redundant test and add add parametrized values instead
2022-11-12 13:38:47 +01:00
bastimeyer
2bf6ee4508 logger: add new log level "all" 2022-11-12 11:37:18 +01:00
Ian Cameron
7908e54062 plugins.vtvgo: update to get required cookies 2022-11-11 18:43:10 +01:00
bastimeyer
57d88a5fa0 plugins.twitch: add --twitch-access-token-param 2022-11-11 09:39:47 -08:00
bastimeyer
773c97b371 build: add urllib3 directly and set it to >=1.26.0
Streamlink currently sets the version range of its `requests` dependency
to `>=2.26.0,<3.0`. `requests` however still defines its `urllib3`
dependency version range as `>=1.21.1,<1.27` in its `2.26.0`-`2.28.1`
releases, including its current state in git.

Recent fixes in Streamlink's HLS implementation unfortunately were made
with methods which are only supported by `urllib3 >=1.26.0`.
This obviously breaks installs with older versions of `urllib3`
installed which are still supported by the defined version range.

In order to avoid having to backport more `urllib3` stuff, moving it
from a transitive dependency and defining it as a direct dependency
with a specific version range set to `>=1.26.0` makes more sense when
fixing the issue. This doesn't conflict with the version range defined
by `requests` and forces a bump of old installs of `urllib3`.

`urllib3==1.26.0` was released on 2020-11-10, whereas
`requests==2.26.0`, was released on 2021-07-13, the lowest version
of the version range defined by Streamlink.

---

In addition to defining the direct `urllib3` dependency, also remove
old compatibility workarounds/bugfixes from `plugin.api.http_session`.
2022-11-11 09:38:48 -08:00
bastimeyer
ed88bcaac0 stream.hls: add more debug messages to write calls 2022-11-10 22:08:36 +01:00
bastimeyer
7039b4b3a1 tools: move list of files to mypy config
- Move list of files from CI config to mypy config in pyproject.toml,
  so that mypy can be run locally without having to specificy the same
  inputs as CLI arguments. Keep --no-incremental exclusive to CI runner.
- Update Python version of mypy CI runner.
- Fix typing ignore comment when importing importlib_metadata fallback
  in the streamlink_cli.compat module.
2022-11-08 13:24:47 +01:00
bastimeyer
ca4fff1453 chore: fix new mypy warnings and errors 2022-11-07 15:16:51 -08:00
Ian Cameron
fc19ae58d0 plugins.bloomberg: update/fix headers to avoid bot detection 2022-11-02 21:14:43 +01:00
streamlinkbot
76769e3f87 plugin.api: update useragents 2022-11-01 00:20:01 +00:00
bastimeyer
6aa2b56e35 plugins.dailymotion: fix validation schema 2022-10-28 09:40:27 -07:00
bastimeyer
37dc0b2029 plugins.tvp: rewrite and fix plugin, add VODs 2022-10-27 19:14:47 -07:00
bastimeyer
55649ecc2a plugins.tf1: rewrite plugin, add "stream" VODs
Co-Authored-By: BZHDeveloper <inizan.yannick@gmail.com>
2022-10-18 11:17:30 -07:00
bastimeyer
e4166bcc12 plugins.btv: fix validation schema 2022-10-14 22:17:56 +02:00
Ian Cameron
a556304742 plugins.tv8: update stream URL regex 2022-10-14 22:17:20 +02:00
bastimeyer
bfcd3725c5 plugins.atresplayer: update input URLs 2022-10-09 17:10:25 -07:00
bastimeyer
26e915e391 plugins.goltelevision: add missing HTTP headers 2022-10-09 17:10:11 -07:00
bastimeyer
204c5b565d plugins.tvrplus: rewrite plugin 2022-10-07 15:10:07 -07:00
bastimeyer
49f54d886d plugins.qq: rewrite and fix plugin 2022-10-04 09:58:09 -07:00
bastimeyer
e665938d93 plugins.egame: remove plugin 2022-10-04 17:52:31 +01:00
bastimeyer
d17cf06d61 plugins.sbscokr: rewrite and fix plugin 2022-10-03 21:44:29 -07:00
bastimeyer
d82184af1d stream.ffmpegmux: validate FFmpeg version
and log FFmpeg version output on the debug logging level
2022-10-02 12:17:39 -07:00