1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2013 Team XBMC
6 # This Program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This Program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with XBMC; see the file COPYING. If not, see
18 # <http://www.gnu.org/licenses/>.
24 from xml.dom import minidom
26 def parseShow(seriesID, show_name):
27 safe_show_name = show_name.replace(":", "")
28 details_url = "http://thetvdb.com/api/EB49E8B9E78EBEE1/series/"+seriesID+"/all/en.xml"
29 details = openAnything.fetch(details_url)
30 details_xml = minidom.parseString(details['data'])
31 seasons = details_xml.getElementsByTagName("SeasonNumber")
32 episodes = details_xml.getElementsByTagName("EpisodeNumber")
33 # check to see if parent show path needs to be made
34 if not os.access(safe_show_name, os.F_OK):
35 os.makedirs(safe_show_name)
38 season = seasons[i].firstChild.data
39 episode = item.firstChild.data
40 filename = safe_show_name+" S"+season+"E"+episode+".avi"
41 # seeif season path exists or not, and make it if not
42 if os.access(safe_show_name + "\\Season " + season, os.F_OK):
43 # just go ahead and create the file
44 file = open(safe_show_name + "\\Season " + season + "\\" + filename, "w")
47 os.makedirs(safe_show_name + "\\Season " + season)
48 file = open(safe_show_name + "\\Season " + season + "\\" + filename, "w")
50 print "Creating %s" % filename
53 show_file = open("shows.txt")
54 shows = show_file.read().split("\n")
57 show_url = "http://thetvdb.com/api/GetSeries.php?"+urllib.urlencode({"seriesname":item})
58 print "Building "+item+"..."
59 show_xml = openAnything.fetch(show_url)
60 xmldoc = minidom.parseString(show_xml['data'])
61 node = xmldoc.getElementsByTagName("seriesid")
63 seriesID = node[0].firstChild.data
64 parseShow(seriesID, item)
66 print "Could not find any data for "+show_name+" on TVDB.\nURL: "+show_url