Created
June 11, 2013 16:56
-
-
Save blha303/5758581 to your computer and use it in GitHub Desktop.
TV show cover downloader | Uses thetvdb.com's api | Run ./getcovers.sh in your TV show root folder
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
#!/bin/bash | |
apikey="APIKEY HERE" | |
folderlist=`ls -d -- */` | |
while read p | |
do | |
echo "$p" | |
url=`python /media/audvid/sorted/Videos/TV/getposterurl.py $apikey $p` | |
cd "$p" | |
wget $url -O cover.jpg | |
if [ $? -ne 0 ] | |
then echo "$p" >> errorlist | |
fi | |
cd .. | |
done < $folderlist |
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 python2 | |
# TV show cover downloader, by blha303 <[email protected]> | |
# Released under the BSD license | |
# Called with 'python getposterurl.py <APIKEY> <SEARCH>... | |
# Example: python getposterurl.py <APIKEY> Game of Thrones | |
# returns http://thetvdb.com/banners/posters/121361-3.jpg | |
import xmltodict | |
from urllib2 import urlopen | |
from sys import argv | |
apikey = argv[1] | |
name = "%20".join(argv[2:]) | |
name = name.replace("/", "") | |
apiurl = "http://thetvdb.com/api/%s/" % apikey | |
searchurl = "http://thetvdb.com/api/GetSeries.php?seriesname=%s" % name | |
seriesurl = apiurl + "series/%s" | |
bannerurl = "http://thetvdb.com/banners/" | |
searchpage = xmltodict.parse(urlopen(searchurl).read()) | |
if name == "FM": | |
try: | |
seriesid = searchpage["Data"]["Series"][1]["seriesid"] | |
except KeyError: | |
seriesid = searchpage["Data"]["Series"]["seriesid"] | |
else: | |
try: | |
seriesid = searchpage["Data"]["Series"][0]["seriesid"] | |
except KeyError: | |
seriesid = searchpage["Data"]["Series"]["seriesid"] | |
seriespage = xmltodict.parse(urlopen(seriesurl % seriesid).read()) | |
print bannerurl + seriespage["Data"]["Series"]["poster"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment