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

Destination and Windows UNC path #2126

Closed
viceroycowboy opened this issue Dec 21, 2021 · 13 comments
Closed

Destination and Windows UNC path #2126

viceroycowboy opened this issue Dec 21, 2021 · 13 comments

Comments

@viceroycowboy
Copy link

viceroycowboy commented Dec 21, 2021

Hello guys can you tell me how to download files correctly with a windows path like this

\192.168.2.200\username\folder\folder

now I have only

[twitter][error] Unable to download data: OSError: [WinError 123]

Can't mount folder like a network drive because VPN broadcasting issues

Python 3.10.1

@Hrxn
Copy link
Contributor

Hrxn commented Dec 21, 2021

ac80474

#2113 (comment)

@mikf
Copy link
Owner

mikf commented Dec 21, 2021

\192.168.2.200\username\folder\folder

Don't UNC paths have to start with a double (back)slash? I'm asking because the code from ac80474 checks for just that to determin whether a path is UNC or not.

@Hrxn
Copy link
Contributor

Hrxn commented Dec 22, 2021

Yep, should be a double backslash.

Here's the syntax in ABNF taken from the MSFT docs for Windows Common Data Types:

 UNC                = "\\" host-name "\" share-name  [ "\" object-name ]
 host-name          = IPv6address / IPv4address / reg-name  
    ; IPv4address, and reg-name are as specified in [RFC3986], see following for IPV6
 share-name         = 1*80pchar
 pchar              = %x20-21 / %x23-29 / %x2D-2E / %x30-39 / %x40-5A / %x5E-7B / %x7D-FF  
 object-name        = *path-name [ "\" file-name ]
 path-name          = 1*255pchar
 file-name          = 1*255fchar [ ":" stream-name [ ":" stream-type ] ]
 fchar              = %x20-21 / %x23-29 / %x2B-2E / %x30-39 / %x3B / %x3D / %x40-5B / %x5D-7B / %x7D-FF 
 stream-name        = *schar
 schar              = %x01-2E / %x30-39 / %x3B-5B /%x5D-FF
 stream-type        = 1*schar

@AlttiRi
Copy link

AlttiRi commented Dec 23, 2021

Don't UNC paths have to start with a double (back)slash?

It's just the GitHub's editor turns \\ to \.

@viceroycowboy
Copy link
Author

Guys soo how much backslashes I should use?

@Hrxn
Copy link
Contributor

Hrxn commented Dec 24, 2021

Two backslashes..

Like this:

\\192.168.2.200\username\folder\folder

@viceroycowboy
Copy link
Author

Two backslashes..

Like this:

\\192.168.2.200\username\folder\folder

[twitter][error] Unable to download data: OSError: [WinError 123] Синтаксическая ошибка в имени файла, имени папки или метке тома: '\\'

@AlttiRi
Copy link

AlttiRi commented Dec 27, 2021

Well, with the last version, gallery-dl does not work when I run it in a network folder:

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\\\\'
[gallery-dl][debug] Version 1.20.0-dev
[gallery-dl][debug] Python 3.9.9 

Traceback (most recent call last):
  File "...\Python\Python39\lib\site-packages\gallery_dl\job.py", line 80, in run
    self.dispatch(msg)
  File "...\Python\Python39\lib\site-packages\gallery_dl\job.py", line 124, in dispatch
    self.handle_url(url, kwdict)
  File "...\Python\Python39\lib\site-packages\gallery_dl\job.py", line 220, in handle_url
    pathfmt.set_filename(kwdict)
  File "...\Python\Python39\lib\site-packages\gallery_dl\path.py", line 202, in set_filename
    self.build_path()
  File "...\Python\Python39\lib\site-packages\gallery_dl\path.py", line 284, in build_path
    os.makedirs(self.realdirectory, exist_ok=True)
  File "...\Python\Python39\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "...\Python\Python39\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "...\Python\Python39\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  [Previous line repeated 2 more times]
  File "...\Python\Python39\lib\os.py", line 225, in makedirs
    mkdir(name, mode)

@AlttiRi
Copy link

AlttiRi commented Dec 27, 2021

A workable fix:

def build_path(self):
"""Combine directory and filename to full paths"""

self.realdirectory = self.realdirectory.replace("\\\\?\\\\\\", "\\\\?\\UNC\\")

@mikf
Copy link
Owner

mikf commented Dec 29, 2021

@AlttiRi What's the exact path you are trying to use? I've tested with \\VBOXSVR\tmp\foobar and other paths longer than 255 characters before committing ac80474 and that worked as excepted.

@AlttiRi
Copy link

AlttiRi commented Dec 29, 2021

git-bash:

cd "//VBOXSVR/tmp" && gallery-dl https://twitter.com/SpaceX/status/1473671809870725121

@AlttiRi
Copy link

AlttiRi commented Dec 30, 2021

Yes, it's Git-Bash' issue since CMD does not support UNC paths as current directories.

mikf added a commit that referenced this issue Jan 1, 2022
always call 'abspath()' on the directory path to handle cases when the
current working directory is UNC and 'base-directory' is relative.
@AlttiRi
Copy link

AlttiRi commented Jan 2, 2022

Looks fixed. (1.20.1-dev)

@mikf mikf closed this as completed Jan 13, 2022
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

4 participants