예제 #1
0
    def _buildEpisode(self, tag, episode, lang):
        target = etree.SubElement(tag, "Targets")
        etree.SubElement(target, "TargetTypeValue").text = "50"
        etree.SubElement(target, "TargetType").text = "EPISODE"

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TheTVDBID"
        etree.SubElement(simple, "String").text = episode['id']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "PART_NUMBER"
        etree.SubElement(simple, "String").text = episode['episode']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DATE_RELEASE"
        etree.SubElement(simple,
                         "String").text = Rfc3339.reverse(episode['release'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "RATING"
        etree.SubElement(simple, "String").text = str(episode['rating'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TITLE"
        etree.SubElement(simple, "String").text = episode['title']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DIRECTOR"
        etree.SubElement(simple, "String").text = episode['director']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "SUMMARY"
        etree.SubElement(simple, "TagLanguage").text = lang
        etree.SubElement(simple, "DefaultLanguage").text = str(1)
        etree.SubElement(simple, "String").text = episode['overview']

        for guest in episode['guests']:
            simple = etree.SubElement(tag, "Simple")
            etree.SubElement(simple, "Name").text = "ACTOR"
            etree.SubElement(simple, "String").text = guest
예제 #2
0
    def _buildEpisode(self, tag, episode, lang):
        target = etree.SubElement(tag, "Targets")
        etree.SubElement(target, "TargetTypeValue").text = "50"
        etree.SubElement(target, "TargetType").text = "EPISODE"

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TheTVDBID"
        etree.SubElement(simple, "String").text = episode['id']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "PART_NUMBER"
        etree.SubElement(simple, "String").text = episode['episode']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DATE_RELEASE"
        etree.SubElement(simple, "String").text = Rfc3339.reverse(episode['release'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "RATING"
        etree.SubElement(simple, "String").text = str(episode['rating'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TITLE"
        etree.SubElement(simple, "String").text = episode['title']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DIRECTOR"
        etree.SubElement(simple, "String").text = episode['director']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "SUMMARY"
        etree.SubElement(simple, "TagLanguage").text = lang
        etree.SubElement(simple, "DefaultLanguage").text = str(1)
        etree.SubElement(simple, "String").text = episode['overview']

        for guest in episode['guests']:
            simple = etree.SubElement(tag, "Simple")
            etree.SubElement(simple, "Name").text = "ACTOR"
            etree.SubElement(simple, "String").text = guest
예제 #3
0
    def film(self, film, lang='fre'):
        tags = etree.XML(
            '''<!DOCTYPE Tags SYSTEM "matroskatags.dtd"><Tags></Tags>''')
        tag = etree.SubElement(tags, "Tag")

        target = etree.SubElement(tag, "Targets")
        etree.SubElement(target, "TargetTypeValue").text = "50"
        etree.SubElement(target, "TargetType").text = "MOVIE"

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "RATING"
        etree.SubElement(simple, "String").text = str(film['vote'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TITLE"
        etree.SubElement(simple, "String").text = film['original_title']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DATE_RELEASE"
        etree.SubElement(simple,
                         "String").text = Rfc3339.reverse(film['release'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TMDbID"
        etree.SubElement(simple, "String").text = str(film['id'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "IMDBID"
        etree.SubElement(simple, "String").text = film['imdb_id']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "GENRE"
        film['genres'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['genres'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DIRECTOR"
        film['directors'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['directors'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "PRODUCER"
        film['producers'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['producers'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "SCREENPLAY_BY"
        film['screenplay'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['screenplay'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "SUMMARY"
        etree.SubElement(simple, "TagLanguage").text = lang
        etree.SubElement(simple, "DefaultLanguage").text = str(1)
        etree.SubElement(simple, "String").text = film['overview']

        for actor in film['actors']:
            simple = etree.SubElement(tag, "Simple")
            etree.SubElement(simple, "Name").text = "ACTOR"
            etree.SubElement(simple, "String").text = actor['name']
            simple1 = etree.SubElement(simple, "Simple")
            etree.SubElement(simple1, "Name").text = "TMDbID"
            etree.SubElement(simple1, "String").text = str(actor['id'])
            simple2 = etree.SubElement(simple, "Simple")
            etree.SubElement(simple2, "Name").text = "CHARACTER"
            etree.SubElement(simple2, "String").text = actor['role']
            simple3 = etree.SubElement(simple, "Simple")
            etree.SubElement(simple3, "Name").text = "URL"
            etree.SubElement(simple3, "String").text = actor['poster']

        root = etree.ElementTree(tags)
        # root.write(sys.stdout, pretty_print=True, xml_declaration=True, encoding="UTF8")
        filename = "{} ({}).xml".format(film['title'].encode('utf8'),
                                        film['release'].strftime('%Y'))
        filename = filename.replace("/", "-")
        root.write(os.path.join(self.destination, filename),
                   pretty_print=True,
                   xml_declaration=True,
                   encoding="UTF8")
        if film['cover']:
            urllib.urlretrieve(
                film['cover'],
                os.path.join(
                    self.destination,
                    'cover{}'.format(os.path.splitext(film['cover'])[1])))
        if film['cover_land']:
            urllib.urlretrieve(
                film['cover_land'],
                os.path.join(
                    self.destination, 'cover_land{}'.format(
                        os.path.splitext(film['cover_land'])[1])))
예제 #4
0
    def film(self, film, lang='fre'):
        tags = etree.XML('''<!DOCTYPE Tags SYSTEM "matroskatags.dtd"><Tags></Tags>''')
        tag = etree.SubElement(tags, "Tag")

        target = etree.SubElement(tag, "Targets")
        etree.SubElement(target, "TargetTypeValue").text = "50"
        etree.SubElement(target, "TargetType").text = "MOVIE"

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "RATING"
        etree.SubElement(simple, "String").text = str(film['vote'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TITLE"
        etree.SubElement(simple, "String").text = film['original_title']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DATE_RELEASE"
        etree.SubElement(simple, "String").text = Rfc3339.reverse(film['release'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "TMDbID"
        etree.SubElement(simple, "String").text = str(film['id'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "IMDBID"
        etree.SubElement(simple, "String").text = film['imdb_id']

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "GENRE"
        film['genres'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['genres'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "DIRECTOR"
        film['directors'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['directors'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "PRODUCER"
        film['producers'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['producers'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "SCREENPLAY_BY"
        film['screenplay'].sort()
        etree.SubElement(simple, "String").text = ", ".join(film['screenplay'])

        simple = etree.SubElement(tag, "Simple")
        etree.SubElement(simple, "Name").text = "SUMMARY"
        etree.SubElement(simple, "TagLanguage").text = lang
        etree.SubElement(simple, "DefaultLanguage").text = str(1)
        etree.SubElement(simple, "String").text = film['overview']

        for actor in film['actors']:
            simple = etree.SubElement(tag, "Simple")
            etree.SubElement(simple, "Name").text = "ACTOR"
            etree.SubElement(simple, "String").text = actor['name']
            simple1 = etree.SubElement(simple, "Simple")
            etree.SubElement(simple1, "Name").text = "TMDbID"
            etree.SubElement(simple1, "String").text = str(actor['id'])
            simple2 = etree.SubElement(simple, "Simple")
            etree.SubElement(simple2, "Name").text = "CHARACTER"
            etree.SubElement(simple2, "String").text = actor['role']
            simple3 = etree.SubElement(simple, "Simple")
            etree.SubElement(simple3, "Name").text = "URL"
            etree.SubElement(simple3, "String").text = actor['poster']

        root = etree.ElementTree(tags)
        # root.write(sys.stdout, pretty_print=True, xml_declaration=True, encoding="UTF8")
        filename = "{} ({}).xml".format(film['title'].encode('utf8'), film['release'].strftime('%Y'))
        filename = filename.replace("/", "-")
        root.write(os.path.join(self.destination, filename), pretty_print=True, xml_declaration=True, encoding="UTF8")
        if film['cover']:
            urllib.urlretrieve(film['cover'], os.path.join(self.destination, 'cover{}'.format(os.path.splitext(film['cover'])[1])))
        if film['cover_land']:
            urllib.urlretrieve(film['cover_land'], os.path.join(self.destination, 'cover_land{}'.format(os.path.splitext(film['cover_land'])[1])))