Last active 1458535125

A script that loads the given (list of) urls, waits for there to be a video tag on the page, then starts downloading the video using the page url as a filename (e.g http://example.com/my-show/episode-1 will produce my-show.episode-1.mp4)

Revision aa930e12fb0dfa8981dcbbbaaa504d0a0440da2c

getvideourl.py Raw
1#!/usr/bin/env python3
2# pip install selenium, you'll also need firefox installed
3
4import contextlib
5from selenium import webdriver
6from selenium.webdriver.support.ui import WebDriverWait
7from selenium.webdriver.support import expected_conditions as EC
8from sys import argv, stderr, stdin
9
10if len(argv) > 1:
11 if argv[1] == "-":
12 urls = [line for line in stdin]
13 else:
14 urls = argv[1:]
15 with contextlib.closing(webdriver.Firefox()) as driver:
16 for i in urls:
17 driver.get(i)
18 WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_tag_name('video'))
19 print(driver.title, file=stderr)
20 print(driver.find_element_by_tag_name("video").get_attribute("src"))