arzkar / ao3-cli

A CLI to download from archiveofourown.org using their built-in download option.
Apache License 2.0
9 stars 0 forks source link

Error, No connection adapters were found #3

Closed bloodconfetti closed 2 years ago

bloodconfetti commented 2 years ago

Hi, I apologize ahead of time because I don't really understand anything about Python or script/coding. I changed my directory location to the desired folder. Put my .txt file within that folder. And ran it two different ways, receiving the same error.

This is the first way I ran it: C:\Users\[REDACTED]\Documents\STFicsDL>ao3_cli -i urls.txt -f PDF

This is the second: C:\Users\[REDACTED]\Documents\STFicsDL>ao3_cli -i urls.txt -o C:\Users\[REDACTED]\Documents\STFicsDL -f PDF

Here is the error:

Processing https://archiveofourown.org/works/33413554
  0%|                                                                                        | 0/19633, ?file/s, ETA: ?
Traceback (most recent call last):
  File "c:\python 3.9.1\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python 3.9.1\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python 3.9.1\Scripts\ao3_cli.exe\__main__.py", line 7, in <module>
  File "c:\python 3.9.1\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\python 3.9.1\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\python 3.9.1\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python 3.9.1\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\python 3.9.1\lib\site-packages\ao3_cli\cli.py", line 44, in run_cli
    fic.get_fic_with_infile(infile)
  File "c:\python 3.9.1\lib\site-packages\ao3_cli\utils\fetch_data.py", line 67, in get_fic_with_infile
    fic.get_fic_metadata(self.format_type)
  File "c:\python 3.9.1\lib\site-packages\ao3_cli\utils\ao3.py", line 23, in get_fic_metadata
    response = self.session.get(self.BaseUrl, params=params)
  File "c:\python 3.9.1\lib\site-packages\requests\sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "c:\python 3.9.1\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\python 3.9.1\lib\site-packages\requests\sessions.py", line 649, in send
    adapter = self.get_adapter(url=request.url)
  File "c:\python 3.9.1\lib\site-packages\requests\sessions.py", line 742, in get_adapter
    raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for 'https://archiveofourown.org/works/33413554'
arzkar commented 2 years ago

requests.exceptions.InvalidSchema: No connection adapters were found for 'https://archiveofourown.org/works/33413554'

According to the above error, your url is https://archiveofourown.org/works/33413554. It should be https://archiveofourown.org/works/33413554

So your command should be-

ao3_cli -u https://archiveofourown.org/works/33413554
bloodconfetti commented 2 years ago

Only I'm not trying to run a single URL. I'm asking it to retrieve the URLs for multiple fics from a txt file.

Here's some examples of the URLs on the list:

https://archiveofourown.org/works/33413554
https://archiveofourown.org/works/33072577
https://archiveofourown.org/works/33408673
https://archiveofourown.org/works/23343487
https://archiveofourown.org/works/33400450
https://archiveofourown.org/works/27888040
https://archiveofourown.org/works/33396781
https://archiveofourown.org/works/33391144
https://archiveofourown.org/works/33391093
https://archiveofourown.org/works/33389866
https://archiveofourown.org/works/33389179

urls.txt

arzkar commented 2 years ago

I see. Lemme see if i can find a way to fix this.

bloodconfetti commented 2 years ago

Take your time! Not in a rush :) Happy holidays!

arzkar commented 2 years ago

I have added a fix which should fix this issue. Please test if it works by installing the cli directly from github using-

pip install git+https://github.com/arzkar/ao3-cli@main

If this solves the issue, let me know.

bloodconfetti commented 2 years ago

It didn't unfortunately... But I can't help but think it's probably user error. Python's been acting a bit odd tonight, and I had to uninstall and reinstall everything due to weird errors. But that was just guesswork from the beginning so there's probably something off on my end. Either way though, the same thing occurred. And then I tried removing the first URL in case that specifically was problematic for some reason. Tried it again. Didn't work for the next URL down in the .txt file either. Please let me know if any further information would be helpful to you. Totally get if you agree it may be user error only.

arzkar commented 2 years ago

The issue has to do with the .txt file. There's some invalid characters in some of the lines. I have added another commit. Reinstall the cli using pip install git+https://github.com/arzkar/ao3-cli@main again and see if its fixed.

bloodconfetti commented 2 years ago

Hey that's progress! It worked for a second lol. I think this one is just a problem with the question mark in the title, much like the other issue pertaining to forward slashes in titles.

Wait, maybe it didn't work for the first one? I checked my designated folder and there's nothing there but my URL text file.

Anyway, yeah I'm really sure the following error was due to the question mark. I deleted the two URLs it tried to grab and now it says it's working again. I just have to figure out where the PDFs are going??? lol; Idk what I did, but like it looks like it's working.

C:\Users\Jack\Documents\STFicsDL>ao3_cli -i urls.txt -o C:\Users\Jack\Documents\STFicsDL -f PDF

Processing https://archiveofourown.org/works/33072577
Downloaded Howling at the Moon by ChronicBookworm.pdf

Processing https://archiveofourown.org/works/33408673
Downloaded even if it wasn’t life or death? by xllecaightwood.pdf
  0%|                                                                             | 1/19632,  6.10s/file, ETA: 33:14:20
Traceback (most recent call last):
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\Scripts\ao3_cli.exe\__main__.py", line 7, in <module>
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\ao3_cli\cli.py", line 44, in run_cli
    fic.get_fic_with_infile(infile)
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\ao3_cli\utils\fetch_data.py", line 84, in get_fic_with_infile
    self.exit_status = save_data(
  File "C:\Users\Jack\AppData\Local\Programs\Python\Python310\lib\site-packages\ao3_cli\utils\processing.py", line 85, in save_data
    with open(ebook_file, "wb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\Jack\\Documents\\STFicsDLeven if it wasn’t life or death? by xllecaightwood.pdf'
arzkar commented 2 years ago

The files should be in C:\Users\Jack\Documents\ since there's a missing \. You need to add \ after STFicsDL for it to work properly. (There's probably a way for Python to do it automatically, I will look into it). So- ao3_cli -i urls.txt -o C:\Users\Jack\Documents\STFicsDL\ -f PDF

bloodconfetti commented 2 years ago

Oh man, sorry! I didn't realize (probably I didn't read thoroughly enough.) Thank you, that is indeed where they are locating themselves!

arzkar commented 2 years ago

Great. Let me know if all the errors have been solved so that I can close this issue. I will release a new version after I fix the other issue that another user opened so in a week or two you can update to the latest version which will have all the cumulative fixes for all the different errors using-

pip install -U ao3-cli
bloodconfetti commented 2 years ago

Excellent! The errors are gone apart from the special characters issue. Which for me also includes quotation marks. You may close this! Thank you for your responses and being so patient.

Includes asterisks as well.