1

I have wget downloaded in the folder, and I run the following command:

wget.exe -i link_goes_here.mp4 -c -nc -P "K:\Folder\of\Saved\videos"

Is there any way to have this run inside a Python script so I don't have to manually run this command? I have a Python script that has:

print(link)

I'm wondering if there is any way to have the wget perform its download after that print occurs?

Here is the script I am working with:

while True:
    try:
        file=open('recent.txt','a', buffering=1)
        try:
            response=[]
            response=requests.get(API_link,proxies=proxies,headers=headers).text.split('[')[1].split(']')[0]
            response=response.split(',')
            for i in response:
                temp=''
                temp=i.split('"')[1].split('"')[0]
                if temp not in list_:
                    link=''
                    link=starting_part+temp+".mp4"
                    print(link)
                    file.write(link)
                    file.write('\n')
                    list_+=[temp]
            file.close()
            sleep(5)
        except:
            continue    
        print(len(list_))
    except requests.ConnectionError:
        continue
    except requests.exceptions.Timeout:
        continue
    else:
        #print('Something happened\n')
        continue

3 Answers 3

2

If I understand you type that command into a command line. you can use the subprocess library to do this.

import subprocess
command = ["wget.exe", "-i", "https://link.com/video.mp4", "-c", "-nc", '"K:\Folder\of\Saved\videos"']
print(link)
process = subprocess.Popen(command)

I believe this is what your asking if not tell me and I can help :)

Sign up to request clarification or add additional context in comments.

3 Comments

I'm trying to wrap my head around this, but the link in wget is dynamic based on the "print(link)" would that change the fundamental nature of your code? I updated my post with my code for context
Tbh I don't totally understand what you mean but you can use link inside of the command variable command = ["wget.exe", "-i", link, "-c", "-nc", '"K:\Folder\of\Saved\videos"']
I tried it with the 'link' and the flags don't work, I'm not sure about the other flags, but the download directory isn't working. It just downloads to the directory where wget is in
1

Just like @Quintin said

import subprocess
command = ["wget.exe", "-i", link, "-c", "-nc", '"K:\Folder\of\Saved\videos"']
print(link)
process = subprocess.Popen(command)

but instead use link after the -i.

Comments

1

Use subprocess.Popen() to execute terminal commands.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.