Ejemplo n.º 1
0
    def showfull(self, path, img):
        movielt = self.allnfoparse(path)
        content = "<h2> " + movielt.find("title").text
        # original title
        if movielt.find("title").text != movielt.find("originaltitle").text:
            content += " ( org: " + movielt.find("originaltitle").text + " )"
        content += " </h2> "
        # IMG
        content += "<div class='movie'>"
        content += path
        content += "<img src='" + img + "'/>" + "\r\n"

        # Year
        content += "Year: " + movielt.find("year").text + " <br> "
        # Top 250
        t250 = movielt.find("top250").text
        if t250 != 0:
            content += "Top 250: " + t250 + " <br> "
        # Rating
        content += "Rating: " + movielt.find("rating").text + " <br> "
        # Actors
        content +=  "Actors <div id='actors' style='border:1px solid black'>"
        acts = movielt.findall("actor")
        for act in acts:
            content += "<a href='" + self.domain + "actor/" +pidevs.nospachar(act.find("name").text) + "'>" + act.find("name").text + "</a> <br>"
        content +=  "</div>"
        # Credits
        content += "Credits : "
        creds = movielt.findall("director")
        for cred in creds:
            content += "<a href='" + self.domain + "real/" +pidevs.nospachar(cred.text) + "'>" + cred.text + "</a> <br>"
        content += "<hr>"
        creds = movielt.findall("credits")
        for cred in creds:
            content += "<a href='" + self.domain + "real/" +pidevs.nospachar(cred.text) + "'>" + cred.text + "</a> <br>"
        # Genres
        content += "Genre : "
        gens = movielt.findall("genre")
        for gen in gens:
            content += "<a href='" + self.domain + "genre/" +pidevs.nospachar(gen.text) + "'>" + gen.text + "</a> &nbsp; "
        content += "<br>"

        #for elem in movielt:
        #    if elem.tag not in ["title", "actor", "year", "credits", "genre", "rating", "originaltitle", "top250", "director", ""]:
        #        content += elem.tag + " : "
        #        if "text" in elem:
        #            content += elem.text
        #        content += "<br>"

        content += "</div>"
        return content
Ejemplo n.º 2
0
    def nfoparse(self, path):
        data = {}
        try:
            tree = ET.parse(path)
        except ET.ParseError:
            self.content += "ERROR ON PARSE" + path
            return data
        root = tree.getroot()

        movielt = root

        data["title"] = movielt.find("title").text
        data["note"] = movielt.find("rating").text
        data["year"] = movielt.find("year").text
        data["path"] = path
        data["id"] = movielt.find("id").text

        # DIrectores
        real = movielt.findall("director")
        if len(real) > 0 and real[0].text != None:
            data["director"] = {}
            for r in real:
                sho = pidevs.nospachar(r.text)
                data["director"][sho] = r.text
        # Image du film
        th = movielt.findall("thumb")
        if len(th) > 0:
            data["img"] = th[0].text
        else:
            data["img"] = self.domain + "no.png"

        if self.MO.find(data["id"]) == None:
            self.MO.insert( data )
        return data
Ejemplo n.º 3
0
 def getReal(self, real):
     self.content = ""
     self.simi = ""
     for mov in self.parcourir():
         print mov
         inf = self.nfoparse(mov)
         if "director" in inf:
             for di in inf["director"]:
                 if pidevs.nospachar(di) == real:
                     self.content += self.show(inf)
                 elif LEVEN and Levenshtein.distance( pidevs.cleantext(pidevs.nospachar(di)), pidevs.cleantext(real)) < 5:
                     self.simi += " LEV " + pidevs.cleantext(pidevs.nospachar(di)) + " - " + pidevs.cleantext(real) + " = " + Levenshtein.distance(pidevs.cleantext(pidevs.nospachar(di)), pidevs.cleantext(real))
                     self.simi += self.show(inf)
                 else:
                     pass
     html = "<h2> Real : " + real + " </h2> " + self.content
     if LEVEN:
         html += " <hr> <h2> Similaires </h2> " + self.simi
     return html