Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urls being used as path #402

Closed
ghost opened this issue Aug 28, 2019 · 9 comments
Closed

urls being used as path #402

ghost opened this issue Aug 28, 2019 · 9 comments

Comments

@ghost
Copy link

ghost commented Aug 28, 2019

when i try to download via the command line, returns the error

C:\Users\mattl>gallery-dl https://twitter.com/veemogallery
[twitter][error] Unable to download data:  OSError: [WinError 123] La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte: '\\\\?\\C:\\Users\\mattl\\gallery- dl\\twitter\\veemogallery\\\\'

this would translate to "The syntax of the file name, of directory or of volume is incorect: '\\?\C:\Users\mattl\gallery- dl\twitter\veemogallery\\'

@ghost
Copy link
Author

ghost commented Aug 28, 2019

actually a verbose would probably be more usefull

C:\Users\mattl>gallery-dl -v https://twitter.com/veemogallery
[gallery-dl][debug] Version 1.10.3-dev
[gallery-dl][debug] Python 3.6.7 - Windows-10-10.0.17134-SP0
[gallery-dl][debug] requests 2.20.1 - urllib3 1.24.3
[gallery-dl][debug] Starting DownloadJob for 'https://twitter.com/veemogallery'
[gallery-dl][debug] Updating urllib3 ciphers
[twitter][debug] Using TwitterTimelineExtractor for 'https://twitter.com/veemogallery'
[twitter][error] Unable to download data:  OSError: [WinError 123] La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte: '\\\\?\\C:\\Users\\mattl\\gallery-dl\\twitter\\veemogallery\\\\'
[twitter][debug]
Traceback (most recent call last):
  File "c:\users\mattl\appdata\local\programs\python\python36\lib\site-packages\gallery_dl\job.py", line 48, in run
    self.dispatch(msg)
  File "c:\users\mattl\appdata\local\programs\python\python36\lib\site-packages\gallery_dl\job.py", line 97, in dispatch
    self.handle_directory(msg[1])
  File "c:\users\mattl\appdata\local\programs\python\python36\lib\site-packages\gallery_dl\job.py", line 251, in handle_directory
    self.initialize(keywords)
  File "c:\users\mattl\appdata\local\programs\python\python36\lib\site-packages\gallery_dl\job.py", line 310, in initialize
    self.pathfmt.set_directory(keywords)
  File "c:\users\mattl\appdata\local\programs\python\python36\lib\site-packages\gallery_dl\util.py", line 635, in set_directory
    os.makedirs(self.realdirectory, exist_ok=True)
  File "c:\users\mattl\appdata\local\programs\python\python36\lib\os.py", line 220, in makedirs
    mkdir(name, mode)
OSError: [WinError 123] La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte: '\\\\?\\C:\\Users\\mattl\\gallery-dl\\twitter\\veemogallery\\\\'

@Hrxn
Copy link
Contributor

Hrxn commented Aug 28, 2019

Can you try it with gallery-dl -v --ignore-config <URL>?

@ghost
Copy link
Author

ghost commented Aug 28, 2019

it returns the exact same error

@f2d
Copy link

f2d commented Aug 29, 2019

Just encountered this error in v1.10.2 (latest from pip) on Win7, uninstalled, reinstalled v1.10.1, working again.

At first I thought it was something bad with my path formats, but no.

@Hrxn
Copy link
Contributor

Hrxn commented Aug 29, 2019

Okay, seems like a regression then.

makedirs function:
https://github.com/python/cpython/blob/e64f948e762a6b9fd02e2902ccf42438df6fcb61/Lib/os.py#L196-L226

error raised here:

try:
    mkdir(name, mode)
except OSError:
    # Cannot rely on checking for EEXIST, since the operating system
    # could give priority to other errors like EACCES or EROFS
    if not exist_ok or not path.isdir(name):
        raise

Called here from utils.py

    # Enable longer-than-260-character paths on Windows
    if os.name == "nt":
        self.realdirectory = "\\\\?\\" + os.path.abspath(directory) + sep
    else:
        self.realdirectory = directory


    # Create directory tree
    os.makedirs(self.realdirectory, exist_ok=True)

Changes in 3284c62 and e77a656 , added in 0bb8737

Hm, what's with that additional trailing sep?

@mikf mikf closed this as completed in 0ce9816 Aug 29, 2019
@mikf
Copy link
Owner

mikf commented Aug 29, 2019

The additional sep was necessary in Python 3.7, the one version I tested with on Windows, because os.path.abspath(directory) removes any \ at the end of a path. It doesn't on Python 3.6, which resulted in two \ at the end and Windows doesn't like that, it seems.

@Hrxn
Copy link
Contributor

Hrxn commented Aug 29, 2019

Ah, okay. Yeah that explains why it was working for me..

So much for Windows being a "first class citizen" in Python, and already considered as "stable" and "reliable" 🙄

@mikf
Copy link
Owner

mikf commented Aug 29, 2019

Oh, it is, as long as you stick to the standard library functions for path manipulation and so on. But I decided to spin my own solution and made too many assumptions along the way. Basically it's my own fault for "disobeying the rules", but os.path.join(a, b) for example is so much slower than a + b that I couldn't help it ... and lets ignore the fact that I shouldn't be caring about speed when using Python in the first place.

@Hrxn
Copy link
Contributor

Hrxn commented Aug 30, 2019

... and lets ignore the fact that I shouldn't be caring about speed when using Python in the first place.

True, true. But I guess the limiting factor in what gallery-dl actually does is basically always the speed of the packets crawling through those thick pipes towards your network interface. The language to solve that needs to be invented first..

And on the other hand, they apparently changed the behaviour of the abspath function in os.path between Python 3.6 and Python 3.7, so any reason notwithstanding, they deserve at least some of the blame. At least I feel that my feigned righteous indignation is somewhat justified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants