Created
October 18, 2018 20:38
-
-
Save dvdbng/588a415515b19810a1d89c576f7f86cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Usage: subscene-dl <subscene url> > file.srt | |
Example: | |
subscene-dl https://subscene.com/subtitles/mr-mercedes-second-season/english/1864622 > Mr.Mercedes.S02E09.WEBRip.x264-ION10.srt | |
""" | |
from lxml import html | |
import requests | |
import sys | |
import zipfile | |
from io import BytesIO | |
page = requests.get(sys.argv[1]) | |
dl = html.fromstring(page.content).xpath('//*[@id="downloadButton"]') | |
dl_url = 'http://www.subscene.com' + dl[0].get('href') | |
with zipfile.ZipFile(BytesIO(requests.get(dl_url).content), 'r') as zf: | |
sys.stdout.buffer.write(zf.read(zf.namelist()[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment