Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: refactor FileOutput and Formatter #4085

Merged
merged 1 commit into from
Oct 10, 2021

Conversation

bastimeyer
Copy link
Member

  • add streamlink_cli.utils.path.replace_path
  • refactor streamlink_cli.utils.formatter.Formatter
    • rename filename() to path() and return a pathlib.Path object
    • format path parts separately
    • replace dot and double-dot path parts if not explicit user input
    • replace unsupported chars in path parts (like before)
  • refactor streamlink_cli.output.FileOutput
    • turn filename into a Path object
    • create parent directories before creating the file descriptor
  • update streamlink_cli.main accordingly
  • update and add new tests

resolves #4081

$ streamlink -o '{author}/{category}/{title}.ts' twitch.tv/dota2ti best
[cli][info] Found matching plugin twitch for URL twitch.tv/dota2ti
[cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
[cli][info] Opening stream: 1080p60 (hls)
[plugins.twitch][info] Will skip ad segments
[plugins.twitch][info] Low latency streaming (HLS live edge: 2)
[plugins.twitch][info] Waiting for pre-roll ads to finish, be patient
[stream.hls][info] Filtering out segments and pausing stream output                                                                     [stream.hls][info] Resuming stream output
[download][.. - Group Stage Day 4.ts] Written 8.0 MB (9s @ 839.8 KB/s)                                                                          ^C[cli][info] Stream ended
Interrupted! Exiting...
[cli][info] Closing currently open stream...

$ ls dota2ti/Dota\ 2/Dota\ 2\ The\ International\ -\ Group\ Stage\ Day\ 4.ts 
'dota2ti/Dota 2/Dota 2 The International - Group Stage Day 4.ts'

- add streamlink_cli.utils.path.replace_path
- refactor streamlink_cli.utils.formatter.Formatter
  - rename filename() to path() and return a pathlib.Path object
  - format path parts separately
  - replace dot and double-dot path parts if not explicit user input
  - replace unsupported chars in path parts (like before)
- refactor streamlink_cli.output.FileOutput
  - turn filename into a Path object
  - create parent directories before creating the file descriptor
- update streamlink_cli.main accordingly
- update and add new tests
@bastimeyer bastimeyer force-pushed the cli/output/fileoutput branch from f49119b to 743e763 Compare October 10, 2021 14:09
@back-to back-to merged commit e152c53 into streamlink:master Oct 10, 2021
@bastimeyer bastimeyer deleted the cli/output/fileoutput branch October 10, 2021 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create new directory upon no such directory found.
2 participants