Created
January 12, 2013 19:53
-
-
Save pabloalba/4520199 to your computer and use it in GitHub Desktop.
Script para descargar automáticamente subtítulos de subtitulos.es.
Hace un poco de web scraping para obtener el último subtítulo en inglés, que descarga con wget.
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/groovy | |
//http://www.subtitulos.es/ajax_loadShow.php?show=1493&season=1 | |
def shows = [ | |
[id:1493, season:1, directory:"/media/data/Arrow"], | |
[id:382, season:4, directory:"/media/data/Modern.Family"] | |
] | |
def getSubtitleURL(feedUrl){ | |
def data = new URL(feedUrl).getText() | |
int pos = data.lastIndexOf("English") | |
data = data.substring(pos) | |
pos = data.indexOf("<a") + 9 | |
data = data.substring(pos) | |
pos = data.indexOf("\"") | |
data = data.substring(0,pos) | |
return data | |
} | |
def download(fileUrl, directory){ | |
def proc = ['wget', '--content-disposition', '--referer="http://www.subtitulos.es"', '-nc', fileUrl].execute(null, new File(directory)) | |
proc.waitFor() | |
} | |
def getSubtitle(show){ | |
def url = "http://www.subtitulos.es/ajax_loadShow.php?show=${show.id}&season=${show.season}" | |
def fileUrl = getSubtitleURL(url) | |
download (fileUrl, show.directory) | |
} | |
//Main feature | |
//For each show, call to getSubtitle | |
shows.each{ | |
getSubtitle(it) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment