Filenames...
See original GitHub issueI’ve run into a few issues with filenames. One of them isn’t entirely Windows specific, and I have an idea of what needs to be done to fix it, but no idea how to. Duplicate filenames within a thread simply overwrite any preceding files. Usually Spoiler_Image
or file.png
.
The other issue is Windows specific and I’ve managed to solve it at least locally by:
from django.utils.text import get_valid_filename
...snip...
img_path = ntpath.join(directory, get_valid_filename(img))
...snip...
The issue in question, filenames like this used to make the script halt on Windows:
C:\vtai>inb4404.py -c -d -l -t https://boards.4channel.org/vt/thread/34806758
[2022-10-11 07:50:46 PM] [ 9/278] vt/34806758/[sound=files.catbox.moe%2F7a2f1v.m4a]{{takanashi kiara}}, {{{1girl}}}, {begging},[[[lipstick]]],[[[lip gloss]]],kusogaki,closed eyes,{{pov}}, {{incoming kiss}}, close-up, {{horny}}, blushing, solo, puffy sleeves, orange skirt, aqua choker, orange hair, ba.png
Traceback (most recent call last):
File "C:\vtai\inb4404.py", line 171, in <module>
main()
File "C:\vtai\inb4404.py", line 31, in main
download_thread(thread, args)
File "C:\vtai\inb4404.py", line 112, in download_thread
with open(img_path, 'wb') as f:
OSError: [Errno 22] Invalid argument: 'C:\\vtai\\downloads\\vt\\34806758\\[sound=files.catbox.moe%2F7a2f1v.m4a]{{takanashi kiara}}, {{{1girl}}}, {begging},[[[lipstick]]],[[[lip gloss]]],kusogaki,closed eyes,{{pov}}, {{incoming kiss}}, close-up, {{horny}}, blushing, solo, puffy sleeves, orange skirt, aqua choker, orange hair, ba.png'
After importing it appears to work.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Filename - Wikipedia
A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose...
Read more >Filenames and file types
The following table lists some examples of filename extensions and the corresponding file type names to use. Extension, File type name .adoc, AsciiDoc...
Read more >FileNames
FileNames [] lists all files in the current working directory. ... FileNames[forms, dirs, n] includes files that are in subdirectories up to n...
Read more >Characters to Avoid in Filenames and Directories
Therefore, it is essential to play it safe and avoid common illegal filename and directory characters. Naming conventions are important in web folders...
Read more >Naming Files, Paths, and Namespaces - Win32 apps
For Windows API functions that manipulate files, file names can often be relative to the current directory, while some APIs require a fully ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added your call of
get_valid_filename
to the script and added the issue of duplicate filenames as a TODO to the README.Oh, and there’s definitely a way to properly parse
Spoiler_Image
filenames since 4chanx and archive sites seem to do it, but I wouldn’t know where to start for that one.