Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Download from youtube
#1
Hello!
I am trying to download video from youtube from.... to

But my attempt does not work

import pytube
link = "https://www.youtube.com/watch?v=u_kgxHZeAoo"
itag = 43
url = pytube.YouTube(link).streams.get_by_itag(itag).url
process_call_str = 'ffmpeg -ss {1} -to {2} -i "{0}"'\
                   '-acodec aac -b:a 192k -avoid_negative_ts make_zero "{3}"'
                            format(str(url), str("00:10:00.00"), str("00:10:56.00"), "C:\Users\Anton")
status = subprocess.check_call(process_call_str, shell=True)
Could anybody help me?
Reply
#2
Could you elaborate on "does not work"?
Reply
#3
Try to run

My output

Output:
C:\Users\Anton\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/Anton/PycharmProjects/SQL/123.py File "C:/Users/Anton/PycharmProjects/SQL/123.py", line 7 format(str(url), str("00:10:00.00"), str("00:10:56.00"), "C:\Users\Anton") ^ IndentationError: unexpected indent Process finished with exit code 1
Reply
#4
you need to dedent line #7
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
I thought it was simple to understand

I need to download certain segment of a video from
for instance 00:34:54 to 00:37:00
but deleting line #7 from this example of code we misinterpret it...
Reply
#6
(Mar-25-2018, 08:43 AM)antonbison Wrote: but deleting line #7 from this example of code we misinterpret it...
I didn't say delete, but dedent (i.e. outdent, remove current indentation)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
Also missing .format.
Need raw string in path r"C:\Users\Anton"
url = 'http://google.com'
process_call = 'ffmpeg -ss {1} -to {2} -i "{0}" -acodec aac -b:a 192k -avoid_negative_ts make_zero "{3}"'.\
format(url, "00:10:00.00", "00:10:56.00", r"C:\Users\Anton")
print(repr(process_call))
Output:
'ffmpeg -ss 00:10:00.00 -to 00:10:56.00 -i "http://google.com" -acodec aac -b:a 192k -avoid_negative_ts make_zero "C:\\Users\\Anton"'
Advice is always write it as list to avoid shell=True(not secure).
Reply
#8
oh, I didn't see that...
snippsat is right
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  download with internet download manager coral_raha 0 2,883 Jul-18-2021, 03:11 PM
Last Post: coral_raha
  How to get python to download YouTube videos in the background? Pythenx 11 10,605 Mar-25-2019, 04:57 AM
Last Post: samsonite

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020