Skip to content

Instantly share code, notes, and snippets.

@boxdot
Last active January 10, 2016 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxdot/6caef69f93a3c107ed7d to your computer and use it in GitHub Desktop.
Save boxdot/6caef69f93a3c107ed7d to your computer and use it in GitHub Desktop.
Print the url for the recent Arte Tracks show.
#!/usr/bin/env python
"""Fetch the url of the recent arte tracks show."""
import re
import sys
import urllib
import requests
# Visit main page of Arte Tacks
resp = requests.get('http://tracks.arte.tv/de/die-sendung')
resp.raise_for_status()
m = re.search('href="(/de/replay[^"]+?)"', resp.content)
if m is None:
raise RuntimeError("Cannot parse 'die-sendung' for video page url")
video_page_url = 'http://tracks.arte.tv{0}'.format(m.group(1))
# Visit recent show page
resp = requests.get(video_page_url)
resp.raise_for_status()
m = re.search('json_url=([^&]+)&', resp.content)
if m is None:
raise RuntimeError(
"Cannot parse '{0}' for video json url".format(video_page_url))
video_json_url = urllib.unquote(m.group(1))
# Fetch video json
resp = requests.get(video_json_url)
resp.raise_for_status()
video = resp.json()
print video['videoJsonPlayer']['VSR']['HTTP_SQ_1']['url']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment