stabbedbybrick / freevine

A Download Utility for Free Streaming Services
MIT License
176 stars 28 forks source link

Folder names might be invalid #89

Open OevreFlataeker opened 8 months ago

OevreFlataeker commented 8 months ago

When I tried to download S02 from https://www.bbc.co.uk/iplayer/episodes/m0015167/marcus-wareings-tales-from-a-kitchen-garden freevine properly downloaded the stream but was not able to store it, as the MPD(?) apparently had a after the end of the name, and Windows foldernames cannot have a blank as the last character. So the folder was created w/o the blank and the subsequent steps to mux failed with "File not found". You can clearly see the additional " " at the end of the directory path in the stacktrace.

To Reproduce

(.venv) F:\freevine>freevine.py get --season  s02 https://www.bbc.co.uk/iplayer/episodes/m0015167/marcus-wareings-tales-from-a-kitchen-garden  -sv res=720
15:34:23.717 INFO : BBC iPlayer
15:34:24.612 INFO : Marcus Wareing's Tales from a Kitchen Garden : 2 Season(s), 30 Episode(s)

Traceback (most recent call last):
  File "c:\Python310\lib\pathlib.py", line 1175, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'downloads\\Marcus Wareings Tales from a Kitchen Garden \\Season 02'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\freevine\freevine.py", line 15, in <module>
    cli()
  File "F:\freevine\.venv\lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "F:\freevine\.venv\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "F:\freevine\.venv\lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "F:\freevine\.venv\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "F:\freevine\.venv\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "F:\freevine\utils\commands.py", line 90, in get
    Service(config, **kwargs)
  File "F:\freevine\services\bbciplayer\bbciplayer.py", line 51, in __init__
    self.get_options()
  File "F:\freevine\services\bbciplayer\bbciplayer.py", line 369, in get_options
    self.download(download, title)
  File "F:\freevine\services\bbciplayer\bbciplayer.py", line 376, in download
    self.save_path = set_save_path(stream, self, title)
  File "F:\freevine\utils\utilities.py", line 441, in set_save_path
    save_path.mkdir(parents=True, exist_ok=True)
  File "c:\Python310\lib\pathlib.py", line 1180, in mkdir
    self.mkdir(mode, parents=False, exist_ok=exist_ok)
  File "c:\Python310\lib\pathlib.py", line 1175, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'downloads\\Marcus Wareings Tales from a Kitchen Garden \\Season 02'

(.venv) F:\freevine>md "\\?\f:\freevine\downloads\Marcus Wareings Tales from a Kitchen Garden "

Expected behavior freevine can handle even erraneous filenames.

Suggestion is to strip() all names/paths so in case something is unexpected it won´t affect the filesystem naming.

stabbedbybrick commented 8 months ago

Good call. It's been fixed in the latest commit: https://github.com/stabbedbybrick/freevine/commit/c3ea99d9d317282bea8084731ba623e88c501cf8