question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’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:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Exceencommented, Nov 9, 2022

I added your call of get_valid_filename to the script and added the issue of duplicate filenames as a TODO to the README.

1reaction
vt-idiotcommented, Oct 12, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found