to download flash videos

This is the place for queries that don't fit in any of the other categories.

to download flash videos

Postby metulburr » Tue Apr 02, 2013 6:12 pm

I think its flash, not sure?

but the cold dead hand video:
http://www.funnyordie.com/videos/0433b3 ... jim-carrey

How would you auto downjload via python?

I checked /tmp directory upon loading the video. But nothing is there?
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1102
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: to donwload flash videos

Postby Yoriz » Tue Apr 02, 2013 6:21 pm

I see this mentioned on python redit the other day, dont know if its any good.
youtube-dl is a small command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter (2.6, 2.7, or 3.3+), and it is not platform specific. It should work in your Unix box, in Windows or in Mac OS X. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.

http://rg3.github.com/youtube-dl/
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 565
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: to download flash videos

Postby snippsat » Tue Apr 02, 2013 7:29 pm

Fast an hacky solution,i look trough source code with chrome-developer-tools(same as Firebug).
In a 2500 lines html file with a lot javascript,i see that file is in mp4 format and they load it with a web flash player.
So as i test i use my Requests script here
Code: Select all
import requests

r = requests.get("http://vo.fod4.com/v/0433b30576/v2500.mp4", stream=True)
with open('cold_dead_jim_carrey.mp4', 'wb') as handle:
    for block in r.iter_content(1024):
        if not block:
            break
        handle.write(block)

Size of file is 111MB,and i got a working mp4 file on my HDD.
User avatar
snippsat
 
Posts: 86
Joined: Thu Feb 21, 2013 12:04 am

Re: to download flash videos

Postby snippsat » Wed Apr 03, 2013 12:46 pm

I looked a little more at Funny or die,and for fun i did write some code that download video to HDD.
Funny or die has 3 quality format of each video,low(110 kbps),medium(600 kbps) and high(2500 kbps)*not all videos has high quality.
To test code paste in url from video you want to download and choose quality(that's all then just run script).
Video will be saved in folder you run script from.
I have only tested code in Windows,will test in Linux later.
Code: Select all
import requests
import re

def funny_id(url='url'):
    '''Take video id from url'''
    url_read = requests.get(url)
    text = url_read.text
    id_vid = re.search(r'''<source src="http://vo.fod4.com/v/(.*)/v600.mp4" />''', text)
    return id_vid.group(1)

def quality(choosen_quality, funny_id):
    '''Choose quality and insert funny_id'''
    vid_quality =\
    {'low': 'http://vo.fod4.com/v//v110.mp4',
     'med':  'http://vo.fod4.com/v//v600.mp4',
     'high': 'http://vo.fod4.com/v//v2500.mp4'}
    adress = vid_quality[choosen_quality]
    first = adress.partition('v/')[:2]
    last = adress.partition('v/')[2:]
    video_adress = '{}{}{}'.format(first[0]+first[1], funny_id, last[0])
    return video_adress

def download(fin_url):
    '''Download given url'''
    req = requests.get(fin_url, stream=True)
    with open('your_video.mp4', 'wb') as handle:
        for block in req.iter_content(4096):
            if not block:
                break
            handle.write(block)

if __name__ == '__main__':
    # Paste in in url from funnyordie
    url = 'http://www.funnyordie.com/videos/4178033806/paris-hilton-responds-to-mccain-ad-censored-from-fod-team'
    #Choose video quality you want(low, med, high)
    video_quality = 'high'

    #-----| Run it |-------
    funny_id = funny_id(url)
    fin_url = quality(video_quality, funny_id)
    download(fin_url)
User avatar
snippsat
 
Posts: 86
Joined: Thu Feb 21, 2013 12:04 am


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 2 guests