开发者

Converting a Youtube Upload into Podcast

There is this youtube channel that uploads one videos per week at exactly the same time every week.开发者_StackOverflow Is it somewhat possible to create a python script that creates a podcast out of it.

What Library should I be learning to make this thing possible or is it even possible in the first place?

Thanks


Interesting. There are legal blah blah blah rights blah blah blah... but you know that already.

I would think if you have a link that auto-plays on page open you could use webbrowser with PyAudio as a simple way to rip the audio from a youtube video. This would require you to play the whole thing and doesn't take into account how long the play time is, but it may get you started.

""" A wire between input and output. """
import pyaudio
import sys
import webbrowser

# open the page
webbrowser.open(AUTOPLAY_URL)

chunk = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5

p = pyaudio.PyAudio()

stream = p.open(format = FORMAT,
            channels = CHANNELS,
            rate = RATE,
            input = True,
            output = True,
            frames_per_buffer = chunk)

print "* recording"
for i in range(0, 44100 / chunk * RECORD_SECONDS):
    data = stream.read(chunk)
    stream.write(data, chunk)
print "* done"

stream.stop_stream()
stream.close()
p.terminate()

This is just code form the pyaudio page. I haven't tried to run it but if your lucky it will work.

How to package and serve the resulting audio file is another issue.


youtube-dl is a python script that can download YouTube movies in the various available formats. It will also do the audio conversion for you if you have the lame mp3 library installed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜