#๐Ÿ”’ python scrip to download files failing

44 messages ยท Page 1 of 1 (latest)

graceful lindenBOT
#

@lofty kestrel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lofty kestrel
#

this is the error message

#

PS C:\Users\kingf> & C:/Users/kingf/AppData/Local/Programs/Python/Python313/python.exe c:/Users/kingf/download_script.py
Download started for: https://www.thingiverse.com/thing:2813926
Renamed 'Aquarium Hideout Rock - 2813926.zip' to '442.zip'
Download started for: https://www.thingiverse.com/thing:2787780
Renamed '442.zip' to '443.zip'
An error occurred with https://www.thingiverse.com/thing:2787780: Message: disconnected: not connected to DevTools
(failed to check if window was closed: disconnected: not connected to DevTools)
(Session info: MicrosoftEdge=129.0.2792.89)
Stacktrace:
GetHandleVerifier [0x00007FF70072CEF5+12997]
Microsoft::Applications::Events::EventProperty::empty [0x00007FF7009ABD24+1897988]
(No symbol) [0x00007FF7004DF1CC]
(No symbol) [0x00007FF7004C868C]
(No symbol) [0x00007FF7004C92EF]
(No symbol) [0x00007FF7004DF738]
(No symbol) [0x00007FF7004BA60D]
(No symbol) [0x00007FF7005551D8]
(No symbol) [0x00007FF700554EDD]
(No symbol) [0x00007FF700547F10]
(No symbol) [0x00007FF70051B5AC]
(No symbol) [0x00007FF70051AA8D]
(No symbol) [0x00007FF70051B171]

graceful lindenBOT
#

:incoming_envelope: :ok_hand: applied timeout to @lofty kestrel until <t:1728780293:f> (10 minutes) (reason: emoji spam - sent 24 emojis).

The <@&831776746206265384> have been alerted for review.

fluid igloo
#

!code

graceful lindenBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

lofty kestrel
#

this is my code

#

but it just renames the already renmaed one

#

any idea how to fix

#

it also waits 1 minute before opening the next url where it should only wait 5 second and open the next in a new tab and only close the first one after 60 seconds

indigo spruce
#

I am trying to get it working on my own machine

#

nvm I saw the problem

#

if I understood properly the original problem is that the same file is getting renamed right?

#

the problem is in the if statement check you have to do the index - 1

#

like this

#
if filename.endswith(".zip") and not filename.startswith(str(file_index - 1)):
#

wait no

#

one sec

lofty kestrel
#

first time trying to program anything

indigo spruce
#

the problem is that when you update the file index for example after the first run

#

the file index is now 443

#

so when it goes through and sees the file index 442.zip it's like woah thats not the index that's supposed to be there and renames that

lofty kestrel
#

i see

#

so how would i fix this, should i try see how to add a way to check if the previouse number is there and if it is to skip that file an look for a diffrent one

indigo spruce
#

I have a question will all of the files you downald

#

will they always start with a letter

#

like I mean will the file name start with a number?

indigo spruce
lofty kestrel
#

they should all start with a letter

indigo spruce
#

ok then what we can do is just check for all the files if the name of the file starts with a letter we rename it but if not then we skip it

lofty kestrel
#

the program is supposed to do this with a few hundred thousand * urls

#

in this case i was thinking of writing a new scrip, after they are all downloaded renamed them starting from the oldest download to the most recent as to save time

indigo spruce
#

you could do that as well yes but you could also just change the condiiton in the if statement to

if filename.endswith(".zip") and not filename[0].isdigit()
#

which checks if the first charecter in the file is a digit

#

also to make it faster

#

instead of calling the rename function everysingle run of the downald thing

#

you could move to after the for loop

#

at the end of the thing

lofty kestrel
#

I will give that a try thank you

indigo spruce
#

alright and if there is any errors please post it back here so I can help

indigo spruce
graceful lindenBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.