sdaqo / anipy-cli

Little tool in python to watch and download anime from the terminal (the better way to watch anime). Also applicable as an API
https://sdaqo.github.io/anipy-cli
GNU General Public License v3.0
260 stars 38 forks source link

Need to clean titles with special Character to valid filename characters #123

Closed Prashanthvsdvn closed 1 year ago

Prashanthvsdvn commented 1 year ago

Describe the bug Downloading shows with special characters result in error creating folders due to special characters. For example, quotation marks are not allowed in Windows paths.

To Reproduce

  1. Open script in Download mode
  2. Search for an anime with special characters
  3. Try to download the anime
  4. Error

Expected behavior Script should strip special characters to create valid file/folder names

Info

Name: anipy-cli
Version: 2.7.10
Summary: Little tool in python to watch anime from the terminal (the better way to watch anime)
Home-page: https://github.com/sdaqo/anipy-cli
Author: sdaqo
Author-email: sdaqo.dev@protonmail.com
License: GPL-3.0
Location: C:\Python311\Lib\site-packages
Requires: beautifulsoup4, better-ffmpeg-progress, m3u8, moviepy, pycryptodomex, pypresence, python-dateutil, python-mpv, pyyaml, requests, setuptools, tqdm
Required-by:

Platform

Additional context Error log

PS D:\Videos\Anime> anipy-cli.exe -D
Discord is not opened, can't initialize Discord Presence
***Download Mode***
Downloads are stored in: D:\Videos\Anime
Search MyAnimeList for anime in Season? (y|n):
>> n
Search: Oshi no ko
Add another search: (y|n)
n

Current:  Oshi no ko
[1] Road to You
[2] "Oshi no Ko"
[3] Hoshi no Koe (Dub)
[4] Joshiochi!: 2-kai kara Onnanoko ga... Futtekita!?
[5] Star☆Twinkle Precure: Hoshi no Uta ni Omoi wo Komete
[6] All-Free kono Natsu Ichioshi Monogatari Campaign Kokuchi Douga
[7] Arifureta Shokugyou de Sekai Saikyou: Maboroshi no Bouken to Kiseki no Kaigou
Enter Number: 2
Episode (Range with '-') [1-1]
>> 1
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Scripts\anipy-cli.exe\__main__.py", line 7, in <module>
  File "C:\Python311\Lib\site-packages\anipy_cli\run_anipy_cli.py", line 8, in main
    cli.run_cli()
  File "C:\Python311\Lib\site-packages\anipy_cli\cli\cli.py", line 37, in run_cli
    cli_class(options=args, rpc_client=rpc_client).run()
  File "C:\Python311\Lib\site-packages\anipy_cli\cli\clis\base_cli.py", line 36, in run
    self.process()
  File "C:\Python311\Lib\site-packages\anipy_cli\cli\clis\download_cli.py", line 86, in process
    download(entry, self.options.quality, self.options.ffmpeg).download()
  File "C:\Python311\Lib\site-packages\anipy_cli\download.py", line 57, in download
    self.show_folder.mkdir(exist_ok=True)
  File "C:\Python311\Lib\pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'D:\\Videos\\Anime\\"Oshi no Ko"'
sdaqo commented 1 year ago

Will look into it

Prashanthvsdvn commented 1 year ago

Hey, the folder side is fixed but file side still remains

PS D:\Videos\Anime> anipy-cli.exe -D
***Download Mode***
Downloads are stored in: D:\Videos\Anime
Search MyAnimeList for anime in Season? (y|n):
>> n
Search: oshi no ko
Add another search: (y|n)
n

Current:  oshi no ko
[1] Road to You
[2] "Oshi no Ko"
[3] Hoshi no Koe (Dub)
[4] Joshiochi!: 2-kai kara Onnanoko ga... Futtekita!?
[5] Star☆Twinkle Precure: Hoshi no Uta ni Omoi wo Komete
[6] All-Free kono Natsu Ichioshi Monogatari Campaign Kokuchi Douga
[7] Arifureta Shokugyou de Sekai Saikyou: Maboroshi no Bouken to Kiseki no Kaigou
Enter Number: 2
Episode (Range with '-') [1-1]
>> 1
--------------------
Downloading: "Oshi no Ko" EP: 1 - hls
Type: m3u8
Downloader:internal
Playlist Index: 0
Resolution at this index: (1920, 1080)

Playlist Index: 1
Resolution at this index: (1280, 720)

Playlist Index: 2
Resolution at this index: (854, 480)

Playlist Index: 3
Resolution at this index: (640, 360)

Quality for Download:(1920, 1080)

Downloading  Part: 1064/1064
Parts Downloaded
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Scripts\anipy-cli.exe\__main__.py", line 7, in <module>
  File "C:\Python311\Lib\site-packages\anipy_cli\run_anipy_cli.py", line 8, in main
    cli.run_cli()
  File "C:\Python311\Lib\site-packages\anipy_cli\cli\cli.py", line 37, in run_cli
    cli_class(options=args, rpc_client=rpc_client).run()
  File "C:\Python311\Lib\site-packages\anipy_cli\cli\clis\base_cli.py", line 36, in run
    self.process()
  File "C:\Python311\Lib\site-packages\anipy_cli\cli\clis\download_cli.py", line 86, in process
    download(entry, self.options.quality, self.options.ffmpeg).download()
  File "C:\Python311\Lib\site-packages\anipy_cli\download.py", line 94, in download
    self.multithread_m3u8_dl()
  File "C:\Python311\Lib\site-packages\anipy_cli\download.py", line 309, in multithread_m3u8_dl
    self.ffmpeg_merge(input_file, audio_input_file)
  File "C:\Python311\Lib\site-packages\anipy_cli\download.py", line 145, in ffmpeg_merge
    merged_video_ts = self.merge_ts_files(input_file)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\anipy_cli\download.py", line 188, in merge_ts_files
    with open(filename, "wb") as merged:
         ^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: 'D:\\Videos\\Anime\\Oshi no Ko\\1_temp/"Oshi no Ko"_1_merged.ts'
sdaqo commented 1 year ago

Sorry about that, it should be fine now.

Quicksilver151 commented 1 year ago

:o i didnt get this as an issue tho how did that happen?

sdaqo commented 1 year ago

Yeah Windows is weird like that sometimes, I guess they just made it random and if you are lucky it can create a file with disallowed characters and sometimes not.

Quicksilver151 commented 1 year ago

ntfs file system strikes again i guess