wayneclub / Subtitle-Downloader

Auto download subtitles from streaming services, such as Apple TV+, CatchPlay, Crunchyroll, Disney+, FridayVideo, HBO GO Asia, iQIYI, iTunes, KKTV, LINE TV, meWATCH, MyVideo, NowE, NowPlayer, Viki, Viu, WeTV, YouTube, and etc.
MIT License
278 stars 60 forks source link

DNSP issue for content with name containing special characters #51

Closed Jayowski closed 10 months ago

Jayowski commented 10 months ago

Hi there,

There is an issue downloading subs from Disney+ (probably other services too) for films/TV shows with name containing special characters, e.g. M*A*S*H*

https://www.disneyplus.com/series/m-a-s-h/319NpA8tlhOI

The script fails to create a folder for such name since it contains special characters, resulting in failed run, please find log below.

Log:

M*A*S*H total: 11 season(s)

Season 1 total: 24 episode(s)   download all episodes

Download: M*A*S*H.S01E01.WEB-DL.DisneyPlus.vtt

Traceback (most recent call last):
  File "D:\Downloads\Subtitle-Downloader-main\subtitle_downloader.py", line 152, in <module>
    main()
  File "D:\Downloads\Subtitle-Downloader-main\subtitle_downloader.py", line 140, in main
    service['class'](args).main()
  File "D:\Downloads\Subtitle-Downloader-main\services\disneyplus\disneyplus.py", line 367, in main
    self.series_subtitle()
  File "D:\Downloads\Subtitle-Downloader-main\services\disneyplus\disneyplus.py", line 172, in series_subtitle
    self.get_subtitle(subtitle_list, program_type,
  File "D:\Downloads\Subtitle-Downloader-main\services\disneyplus\disneyplus.py", line 319, in get_subtitle
    os.makedirs(lang_folder_path, exist_ok=True)
  File "D:\Apps\!P\!Code\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\Apps\!P\!Code\Python\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "D:\Apps\!P\!Code\Python\Python310\lib\os.py", line 225, in makedirs
    mkdir(name, mode)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'D:\\Downloads\\Subtitle-Downloader-main\\downloads\\M*A*S*H.S01'

There is probably more content with special characters in the name so I would probably adjust the special character treatment in the script rather than add an exception for MASH.

Here's the list of Windows special characters:

< (less than)
> (greater than)
: (colon)
" (quote)
/ (forward slash)
\ (backslash)
| (vertical bar)
? (question mark)
* (asterisk)
^ (caret) *FAT

Many thanks for the great coding - you saved me lots of scripting :)

wayneclub commented 10 months ago

special characters:

Thanks for mention. Code updated. Please re-download the project.

Jayowski commented 10 months ago

Update works flawlessly, much appreciated! <3