Exemplo n.º 1
0
    def reload_results(self, results):
        self.result_frame.destroy()

        self.result_frame = ScrollFrame(self, width=1080, height=600)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)

        for i, manga in enumerate(results):
            temp = ttk.Frame(self.result_frame.viewport)

            image = ttk.Label(temp)
            self.main.imager.apply_image_on_label(
                "manga_" + str(manga["mal_id"]) + ".jpg", manga["image_url"],
                image)
            image.pack()

            title = ttk.Button(temp,
                               text=manga["title"],
                               command=lambda m=manga: self.main.show_page(
                                   "manga " + str(m["mal_id"])))
            title.pack(pady=10)

            temp.grid(row=i // 2, column=i % 2, pady=20)

        self.result_frame.viewport.columnconfigure(0, weight=1)
        self.result_frame.viewport.columnconfigure(1, weight=1)
        self.result_frame.pack(pady=(20, 0))
Exemplo n.º 2
0
    def __init__(self, main):
        super(MyManga, self).__init__(main)
        title = ttk.Label(self,
                          text="Mes Mangas",
                          font="-size 22 -weight bold")
        title.pack(pady=15)

        top_frame = ttk.Frame(self)

        self.search = StringVar(self)
        search_entry = ttk.Entry(top_frame, textvariable=self.search, width=30)
        search_entry.bind("<Return>", self.validate_search)
        search_entry.pack(side=LEFT, padx=30)

        self.etat = StringVar(self)
        self.etat.set("Tous")
        etat_select = ttk.OptionMenu(top_frame, self.etat, "Tous", "Tous",
                                     "A voir", "En visionnement", "Fini",
                                     "Abandonné")
        etat_select["width"] = 30
        etat_select.pack(side=LEFT, padx=30)

        top_frame.pack(pady=10)

        bottom_frame = ttk.Frame(self)

        self.exp_imp = StringVar(self)
        self.exp_imp.set("MyAnimeList")
        exp_imp = ttk.OptionMenu(bottom_frame, self.exp_imp, "MyAnimeList")
        exp_imp["width"] = 30
        exp_imp.pack(side=LEFT, padx=20)
        import_ = ttk.Button(bottom_frame,
                             text="Import",
                             width=20,
                             command=self.import_)
        import_.pack(side=LEFT, padx=10)
        export = ttk.Button(bottom_frame,
                            text="Export",
                            width=20,
                            command=self.export_)
        export.pack(side=LEFT, padx=10)

        bottom_frame.pack(pady=10)

        self.result_frame = ScrollFrame(self, width=1080, height=800)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)
        self.result_frame.pack(pady=(10, 0))

        self.validate_state()

        self.pack(side=RIGHT, fill=BOTH)

        self.etat.trace("w", self.validate_state)
        self.validate_state()
Exemplo n.º 3
0
    def __init__(self, main):
        super(ListManga, self).__init__(main)
        self.current_page = 1
        self.current_display = ""

        title = ttk.Label(self,
                          text="Liste Manga",
                          font="-size 22 -weight bold")
        title.pack(pady=15)

        top_frame = ttk.Frame(self)

        self.search = StringVar(self)
        search_entry = ttk.Entry(top_frame, textvariable=self.search, width=30)
        search_entry.bind("<Return>", self.validate_search)
        search_entry.pack(side=LEFT, padx=30)

        self.top = StringVar(self)
        self.top.set("Top Global")
        top_select = ttk.OptionMenu(top_frame, self.top, "Top Global",
                                    "Top Global", "Top Manga", "Top Novels",
                                    "Top Oneshots", "Top Doujin", "Top Manhwa",
                                    "Top Manhua", "Top Populaire",
                                    "Top Favoris")
        top_select["width"] = 30
        top_select.pack(side=LEFT, padx=30)

        top_frame.pack(pady=20)

        bottom_frame = ttk.Frame(self)

        left_page = ttk.Button(bottom_frame,
                               text="<-",
                               width=20,
                               command=self.previous_page)
        left_page.pack(side=LEFT, padx=20)
        self.num_page = ttk.Label(bottom_frame, text="Page 1")
        self.num_page.pack(side=LEFT, padx=20)
        right_page = ttk.Button(bottom_frame,
                                text="->",
                                width=20,
                                command=self.next_page)
        right_page.pack(side=LEFT, padx=20)

        bottom_frame.pack(pady=10)

        self.result_frame = ScrollFrame(self, width=1080, height=600)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)
        self.result_frame.pack(pady=(20, 0))

        self.pack(side=RIGHT, fill=BOTH)

        self.top.trace("w", self.validate_top)
        self.validate_top()
Exemplo n.º 4
0
    def __init__(self, main, mal_id, title):
        super(Episodes, self).__init__(main)
        self.mal_id = mal_id
        self.current_page = int(title.split("_")[0])
        self.last_page = 0
        self.episodes = None
        self.urls = None

        self.title = "_".join(title.split("_")[1:])

        title = ttk.Label(self, text=self.title, font="-size 22 -weight bold")
        title.pack(pady=15)

        bottom_frame = ttk.Frame(self)

        left_page = ttk.Button(bottom_frame,
                               text="<-",
                               width=20,
                               command=self.previous_page)
        left_page.pack(side=LEFT, padx=20)
        self.num_page = ttk.Label(bottom_frame,
                                  text="Page " + str(self.current_page) + "/" +
                                  str(self.last_page))
        self.num_page.pack(side=LEFT, padx=20)
        right_page = ttk.Button(bottom_frame,
                                text="->",
                                width=20,
                                command=self.next_page)
        right_page.pack(side=LEFT, padx=20)

        bottom_frame.pack(pady=10)

        self.scroll = ScrollFrame(self, width=1080, height=600)
        self.scroll.pack_propagate(False)

        self.scroll.pack(pady=10)

        self.back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page("anime " + str(mal_id)))
        self.back.pack(pady=10)

        self.pack(side=RIGHT, fill=BOTH)

        self.reload_results()
Exemplo n.º 5
0
    def __init__(self, main, mal_id, title):
        super(Recommands, self).__init__(main)
        if title.startswith("a_"):
            self.recommandations = self.main.mal.anime(mal_id,
                                                       "recommendations")
            type_ = "anime"
        else:
            self.recommandations = self.main.mal.manga(mal_id,
                                                       "recommendations")
            type_ = "manga"
        title = title[2:]

        title = ttk.Label(self, text=title, font="-size 22 -weight bold")
        title.pack(pady=15)

        scroll = ScrollFrame(self, width=1080, height=630)
        scroll.pack_propagate(False)

        for i, recommandation in enumerate(
                self.recommandations["recommendations"]):
            temp = ttk.Frame(scroll.viewport)

            ttitle = ttk.Label(temp,
                               text=recommandation["title"],
                               font="-weight bold")
            ttitle.pack(pady=(10, 2))
            nr = ttk.Label(temp,
                           text="Nombre recommandation : " +
                           str(recommandation["recommendation_count"]))
            nr.pack(pady=(2, 10))

            image = ttk.Label(temp)
            self.main.imager.apply_image_on_label(
                type_ + "_" + str(mal_id) + "_rec" + str(i) + ".jpg",
                recommandation["image_url"], image)
            image.pack(pady=(10, 5))

            url = ttk.Button(temp,
                             text="Plus d'info",
                             command=lambda a=recommandation: self.main.
                             show_page(type_ + " " + str(a["mal_id"])))
            url.pack(pady=(0, 10))

            temp.grid(row=i // 3, column=i % 3, pady=10, padx=5)

        for i in range(3):
            scroll.viewport.columnconfigure(i, weight=1)

        scroll.pack(pady=10)

        back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page(type_ + " " + str(mal_id)))
        back.pack(pady=15)

        self.pack(side=RIGHT, fill=BOTH)
Exemplo n.º 6
0
    def __init__(self, main, mal_id, title):
        super(News, self).__init__(main)
        if title.startswith("a_"):
            self.news = self.main.mal.anime(mal_id, "news")
            type_ = "anime"
        else:
            self.news = self.main.mal.manga(mal_id, "news")
            type_ = "manga"
        title = title[2:]

        title = ttk.Label(self, text=title, font="-size 22 -weight bold")
        title.pack(pady=15)

        scroll = ScrollFrame(self, width=1080, height=630)
        scroll.pack_propagate(False)

        for article in self.news["articles"]:
            date = datetime.strptime(article["date"],
                                     "%Y-%m-%dT%H:%M:%S+00:00")
            temp = ttk.Frame(scroll.viewport)

            date = ttk.Label(temp,
                             text=str(date.day) + "/" + str(date.month) + "/" +
                             str(date.year))
            date.grid(row=0, column=0, pady=10, padx=(10, 0), sticky="w")
            title = ttk.Label(temp, text=article["title"], font="-weight bold")
            self.main.translator.translate(title, article["title"])
            title.grid(row=0, column=1, pady=10)
            author = ttk.Label(temp, text=article["author_name"])
            author.grid(row=0, column=2, pady=10, padx=(0, 10), sticky="e")

            intro = ttk.Label(
                temp,
                text=article["intro"] if len(article["intro"]) < 130 else
                article["intro"][:127] + "...")
            self.main.translator.translate(intro, article["intro"], 130, 1)
            intro.grid(row=1, column=0, columnspan=3, pady=10)

            url = ttk.Button(temp,
                             text="Lien",
                             command=lambda a=article: open_url(a["url"]))
            url.grid(row=2, column=0, columnspan=3, pady=10)

            for i in range(3):
                temp.columnconfigure(i, weight=1)

            temp.pack(pady=10, fill="x")

        scroll.pack(pady=10)

        back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page(type_ + " " + str(mal_id)))
        back.pack(pady=10)

        self.pack(side=RIGHT, fill=BOTH)
Exemplo n.º 7
0
    def __init__(self, main, mal_id, title):
        super(Characters, self).__init__(main)
        if title.startswith("a_"):
            self.characters = self.main.mal.anime(mal_id, "characters_staff")
            type_ = "anime"
        else:
            self.characters = self.main.mal.manga(mal_id, "characters")
            type_ = "manga"
        title = title[2:]

        title = ttk.Label(self, text=title, font="-size 22 -weight bold")
        title.pack(pady=15)

        scroll = ScrollFrame(self, width=1080, height=630)
        scroll.pack_propagate(False)

        for i, character in enumerate(self.characters["characters"]):
            temp = ttk.Frame(scroll.viewport)

            ttitle = ttk.Label(temp,
                               text=character["name"],
                               font="-weight bold")
            ttitle.pack(pady=10)

            image = ttk.Label(temp)
            self.main.imager.apply_image_on_label(
                type_ + "_" + str(mal_id) + "_cha" + str(i) + ".jpg",
                character["image_url"], image)
            image.pack(pady=(10, 5))

            url = ttk.Button(temp,
                             text="Lien",
                             command=lambda a=character: open_url(a["url"]))
            url.pack(pady=(0, 10))

            temp.grid(row=i // 4, column=i % 4, pady=10, padx=5)

        for i in range(4):
            scroll.viewport.columnconfigure(i, weight=1)

        scroll.pack(pady=10)

        back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page(type_ + " " + str(mal_id)))
        back.pack(pady=15)

        self.pack(side=RIGHT, fill=BOTH)
Exemplo n.º 8
0
    def __init__(self, main, mal_id, title):
        super(Videos, self).__init__(main)
        self.videos = self.main.mal.anime(mal_id, "videos")

        title = ttk.Label(self, text=title, font="-size 22 -weight bold")
        title.pack(pady=15)

        scroll = ScrollFrame(self, width=1080, height=630)
        scroll.pack_propagate(False)

        for i, video in enumerate(self.videos["promo"]):
            temp = ttk.Frame(scroll.viewport)

            ttitle = ttk.Label(temp, text=video["title"], font="-weight bold")
            self.main.translator.translate(ttitle, video["title"])
            ttitle.pack(pady=10)

            image = ttk.Label(temp)
            self.main.imager.apply_image_on_label(
                "anime_" + str(mal_id) + "_vid" + str(i) + ".jpg",
                video["image_url"], image)
            image.pack(pady=(10, 5))

            url = ttk.Button(temp,
                             text="Lien",
                             command=lambda a=video: open_url(a["video_url"]))
            url.pack(pady=(0, 10))

            temp.grid(row=i // 2, column=i % 2, pady=10, padx=5)

        for i in range(2):
            scroll.viewport.columnconfigure(i, weight=1)

        scroll.pack(pady=10)

        back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page("anime " + str(mal_id)))
        back.pack(pady=15)

        self.pack(side=RIGHT, fill=BOTH)
Exemplo n.º 9
0
    def __init__(self, main, mal_id, title):
        super(Images, self).__init__(main)
        if title.startswith("a_"):
            self.pictures = self.main.mal.anime(mal_id, "pictures")
            type_ = "anime"
        else:
            self.pictures = self.main.mal.manga(mal_id, "pictures")
            type_ = "manga"
        title = title[2:]

        title = ttk.Label(self, text=title, font="-size 22 -weight bold")
        title.pack(pady=15)

        scroll = ScrollFrame(self, width=1080, height=630)
        scroll.pack_propagate(False)

        for i, pic in enumerate(self.pictures["pictures"]):
            temp = ttk.Frame(scroll.viewport)

            image = ttk.Label(temp)
            self.main.imager.apply_image_on_label(
                type_ + "_" + str(mal_id) + "_pic" + str(i) + ".jpg",
                pic["small"], image)
            image.bind("<Button-1>", lambda _, url=pic["large"]: open_url(url))
            image.pack()

            temp.grid(row=i // 4, column=i % 4, pady=5, padx=5)

        for i in range(4):
            scroll.viewport.columnconfigure(i, weight=1)

        scroll.pack(pady=10)

        back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page(type_ + " " + str(mal_id)))
        back.pack(pady=15)

        self.pack(side=RIGHT, fill=BOTH)
Exemplo n.º 10
0
    def reload_results(self, results):
        self.result_frame.destroy()

        self.result_frame = ScrollFrame(self, width=1080, height=800)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)

        for i, manga in enumerate(results):
            temp = ttk.Frame(self.result_frame.viewport, relief=SUNKEN)
            temp.pack_propagate(False)
            temp.config(width=400, height=220)

            title = ttk.Label(temp, text=manga["name"], font="-size 13")
            title.pack(pady=10)
            status = ttk.Label(temp, text="Statut : " + manga["status"])
            status.pack(pady=5)
            ep = ttk.Label(temp,
                           text="Volumes : " + str(manga["vol"]) + "/" +
                           str(manga["max_vol"]))
            ep.pack(pady=5)
            ep = ttk.Label(temp,
                           text="Chapitres : " + str(manga["chap"]) + "/" +
                           str(manga["max_chap"]))
            ep.pack(pady=5)

            buttons = ttk.Frame(temp)

            delete = ttk.Button(
                buttons,
                text="Supprimer",
                width=10,
                command=lambda a=manga: self.delete_manga(a["id"]))
            delete.pack(side=LEFT, padx=10)
            more_info = ttk.Button(buttons,
                                   text="Plus d'info",
                                   command=lambda a=manga: self.main.show_page(
                                       "manga " + str(a["id"])))
            more_info.pack(side=RIGHT, padx=10)
            modify = ttk.Button(buttons,
                                text="Modifier",
                                command=lambda a=manga: self.main.show_page(
                                    "modifmanga " + str(a["id"])))
            modify.pack(padx=10)

            buttons.pack(pady=(15, 3))

            buttons2 = ttk.Frame(temp)
            down_vol = ttk.Button(buttons2,
                                  text="-1 Vol",
                                  width=8,
                                  command=lambda a=manga: self.modify_vol_chap(
                                      a, "vol", a["vol"] - 1))
            down_vol.pack(side=LEFT, padx=10)
            down_chap = ttk.Button(buttons2,
                                   text="-1 Chap",
                                   width=8,
                                   command=lambda a=manga: self.
                                   modify_vol_chap(a, "chap", a["chap"] - 1))
            down_chap.pack(side=LEFT, padx=10)
            up_vol = ttk.Button(buttons2,
                                text="+1 Vol",
                                width=8,
                                command=lambda a=manga: self.modify_vol_chap(
                                    a, "vol", a["vol"] + 1))
            up_vol.pack(side=RIGHT, padx=10)
            up_chap = ttk.Button(buttons2,
                                 text="+1 Chap",
                                 width=8,
                                 command=lambda a=manga: self.modify_vol_chap(
                                     a, "chap", a["chap"] + 1))
            up_chap.pack(side=RIGHT, padx=10)
            buttons2.pack(pady=(3, 15))

            temp.grid(row=i // 2, column=i % 2, pady=20)

        self.result_frame.viewport.columnconfigure(0, weight=1)
        self.result_frame.viewport.columnconfigure(1, weight=1)
        self.result_frame.pack(pady=(10, 0))
Exemplo n.º 11
0
class ListManga(RightPage):
    def __init__(self, main):
        super(ListManga, self).__init__(main)
        self.current_page = 1
        self.current_display = ""

        title = ttk.Label(self,
                          text="Liste Manga",
                          font="-size 22 -weight bold")
        title.pack(pady=15)

        top_frame = ttk.Frame(self)

        self.search = StringVar(self)
        search_entry = ttk.Entry(top_frame, textvariable=self.search, width=30)
        search_entry.bind("<Return>", self.validate_search)
        search_entry.pack(side=LEFT, padx=30)

        self.top = StringVar(self)
        self.top.set("Top Global")
        top_select = ttk.OptionMenu(top_frame, self.top, "Top Global",
                                    "Top Global", "Top Manga", "Top Novels",
                                    "Top Oneshots", "Top Doujin", "Top Manhwa",
                                    "Top Manhua", "Top Populaire",
                                    "Top Favoris")
        top_select["width"] = 30
        top_select.pack(side=LEFT, padx=30)

        top_frame.pack(pady=20)

        bottom_frame = ttk.Frame(self)

        left_page = ttk.Button(bottom_frame,
                               text="<-",
                               width=20,
                               command=self.previous_page)
        left_page.pack(side=LEFT, padx=20)
        self.num_page = ttk.Label(bottom_frame, text="Page 1")
        self.num_page.pack(side=LEFT, padx=20)
        right_page = ttk.Button(bottom_frame,
                                text="->",
                                width=20,
                                command=self.next_page)
        right_page.pack(side=LEFT, padx=20)

        bottom_frame.pack(pady=10)

        self.result_frame = ScrollFrame(self, width=1080, height=600)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)
        self.result_frame.pack(pady=(20, 0))

        self.pack(side=RIGHT, fill=BOTH)

        self.top.trace("w", self.validate_top)
        self.validate_top()

    def next_page(self):
        if self.current_display.startswith("search "):
            self.current_page += 1
            self.reload_results(
                self.main.mal.search(
                    "manga", " ".join(self.current_display.split(" ")[:1]),
                    self.current_page))
        else:
            temp = {
                "Top Global": None,
                "Top Manga": "manga",
                "Top Novels": "novels",
                "Top Oneshots": "oneshots",
                "Top Doujin": "doujin",
                "Top Manhwa": "manhwa",
                "Top Manhua": "manhua",
                "Top Populaire": "bypopularity",
                "Top Favoris": "favorite"
            }
            self.current_page += 1
            self.reload_results(
                self.main.mal.top("manga", self.current_page,
                                  temp[self.current_display]))
        self.num_page["text"] = "Page " + str(self.current_page)

    def previous_page(self):
        if self.current_page != 1:
            if self.current_display.startswith("search "):
                self.current_page -= 1
                self.reload_results(
                    self.main.mal.search(
                        "manga", " ".join(self.current_display.split(" ")[:1]),
                        self.current_page))
            else:
                temp = {
                    "Top Global": None,
                    "Top Manga": "manga",
                    "Top Novels": "novels",
                    "Top Oneshots": "oneshots",
                    "Top Doujin": "doujin",
                    "Top Manhwa": "manhwa",
                    "Top Manhua": "manhua",
                    "Top Populaire": "bypopularity",
                    "Top Favoris": "favorite"
                }
                self.current_page -= 1
                self.reload_results(
                    self.main.mal.top("manga", self.current_page,
                                      temp[self.current_display]))
            self.num_page["text"] = "Page " + str(self.current_page)

    def validate_search(self, *ignore):
        self.current_display = "search " + self.search.get()
        self.current_page = 1
        self.num_page["text"] = "Page " + str(self.current_page)
        self.reload_results(self.main.mal.search("manga", self.search.get()))

    def validate_top(self, *ignore):
        temp = {
            "Top Global": None,
            "Top Manga": "manga",
            "Top Novels": "novels",
            "Top Oneshots": "oneshots",
            "Top Doujin": "doujin",
            "Top Manhwa": "manhwa",
            "Top Manhua": "manhua",
            "Top Populaire": "bypopularity",
            "Top Favoris": "favorite"
        }
        self.current_display = self.top.get()
        self.current_page = 1
        self.num_page["text"] = "Page " + str(self.current_page)
        self.reload_results(self.main.mal.top("manga", 1,
                                              temp[self.top.get()]))

    def reload_results(self, results):
        self.result_frame.destroy()

        self.result_frame = ScrollFrame(self, width=1080, height=600)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)

        for i, manga in enumerate(results):
            temp = ttk.Frame(self.result_frame.viewport)

            image = ttk.Label(temp)
            self.main.imager.apply_image_on_label(
                "manga_" + str(manga["mal_id"]) + ".jpg", manga["image_url"],
                image)
            image.pack()

            title = ttk.Button(temp,
                               text=manga["title"],
                               command=lambda m=manga: self.main.show_page(
                                   "manga " + str(m["mal_id"])))
            title.pack(pady=10)

            temp.grid(row=i // 2, column=i % 2, pady=20)

        self.result_frame.viewport.columnconfigure(0, weight=1)
        self.result_frame.viewport.columnconfigure(1, weight=1)
        self.result_frame.pack(pady=(20, 0))
Exemplo n.º 12
0
    def reload_results(self, results):
        self.result_frame.destroy()

        self.result_frame = ScrollFrame(self, width=1080, height=800)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)

        for i, anime in enumerate(results):
            temp = ttk.Frame(self.result_frame.viewport, relief=SUNKEN)
            temp.pack_propagate(False)
            temp.config(width=400, height=220)

            title = ttk.Label(temp, text=anime["name"], font="-size 13")
            title.pack(pady=15)
            status = ttk.Label(temp, text="Statut : " + anime["status"])
            status.pack(pady=5)
            ep = ttk.Label(temp,
                           text="Episodes : " + str(anime["ep"]) + "/" +
                           str(anime["max_ep"]))
            ep.pack(pady=10)

            buttons = ttk.Frame(temp)

            delete = ttk.Button(
                buttons,
                text="Supprimer",
                width=10,
                command=lambda a=anime: self.delete_anime(a["id"]))
            delete.pack(side=LEFT, padx=10)
            more_info = ttk.Button(buttons,
                                   text="Plus d'info",
                                   width=10,
                                   command=lambda a=anime: self.main.show_page(
                                       "anime " + str(a["id"])))
            more_info.pack(side=RIGHT, padx=10)
            modify = ttk.Button(buttons,
                                text="Modifier",
                                width=10,
                                command=lambda a=anime: self.main.show_page(
                                    "modifanime " + str(a["id"])))
            modify.pack(padx=10)

            buttons.pack(pady=(15, 3))

            buttons2 = ttk.Frame(temp)
            down = ttk.Button(
                buttons2,
                text="-1",
                width=3,
                command=lambda a=anime: self.modify_ep(a, a["ep"] - 1))
            down.pack(side=LEFT, padx=10)
            up = ttk.Button(
                buttons2,
                text="+1",
                width=3,
                command=lambda a=anime: self.modify_ep(a, a["ep"] + 1))
            up.pack(side=RIGHT, padx=10)
            buttons2.pack(pady=(3, 15))

            temp.grid(row=i // 2, column=i % 2, pady=20)

        self.result_frame.viewport.columnconfigure(0, weight=1)
        self.result_frame.viewport.columnconfigure(1, weight=1)
        self.result_frame.pack(pady=(10, 0))
Exemplo n.º 13
0
class Episodes(RightPage):
    def __init__(self, main, mal_id, title):
        super(Episodes, self).__init__(main)
        self.mal_id = mal_id
        self.current_page = int(title.split("_")[0])
        self.last_page = 0
        self.episodes = None
        self.urls = None

        self.title = "_".join(title.split("_")[1:])

        title = ttk.Label(self, text=self.title, font="-size 22 -weight bold")
        title.pack(pady=15)

        bottom_frame = ttk.Frame(self)

        left_page = ttk.Button(bottom_frame,
                               text="<-",
                               width=20,
                               command=self.previous_page)
        left_page.pack(side=LEFT, padx=20)
        self.num_page = ttk.Label(bottom_frame,
                                  text="Page " + str(self.current_page) + "/" +
                                  str(self.last_page))
        self.num_page.pack(side=LEFT, padx=20)
        right_page = ttk.Button(bottom_frame,
                                text="->",
                                width=20,
                                command=self.next_page)
        right_page.pack(side=LEFT, padx=20)

        bottom_frame.pack(pady=10)

        self.scroll = ScrollFrame(self, width=1080, height=600)
        self.scroll.pack_propagate(False)

        self.scroll.pack(pady=10)

        self.back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page("anime " + str(mal_id)))
        self.back.pack(pady=10)

        self.pack(side=RIGHT, fill=BOTH)

        self.reload_results()

    def reload_results(self):
        self.episodes = self.main.mal.anime(self.mal_id, "episodes",
                                            self.current_page)
        self.last_page = self.episodes["episodes_last_page"]
        self.num_page["text"] = "Page " + str(self.current_page) + "/" + str(
            self.last_page)

        self.scroll.destroy()
        self.back.destroy()

        self.scroll = ScrollFrame(self, width=1080, height=580)
        self.scroll.pack_propagate(False)

        if self.last_page == 1:
            max_ep = len(self.episodes["episodes"])
        else:
            max_ep = 100 * self.last_page - 1

        for i, episode in enumerate(self.episodes["episodes"]):
            date = datetime.strptime(episode["aired"],
                                     "%Y-%m-%dT%H:%M:%S+00:00")

            temp = ttk.Frame(self.scroll.viewport)

            ttitle = ttk.Label(temp,
                               text=str(episode["episode_id"]) + " - " +
                               episode["title"],
                               font="-weight bold")
            ttitle.pack(pady=10)

            infos = ttk.Frame(temp)

            date = ttk.Label(infos,
                             text="Date : " + str(date.day) + "/" +
                             str(date.month) + "/" + str(date.year))
            date.pack(side=LEFT, padx=10)
            filler = ttk.Label(infos,
                               text="Filler : " +
                               ("Oui" if episode["filler"] else "Non"))
            filler.pack(side=LEFT, padx=10)
            recap = ttk.Label(infos,
                              text="Recap : " +
                              ("Oui" if episode["recap"] else "Non"))
            recap.pack(side=LEFT, padx=10)

            infos.pack(pady=5)

            btn = ttk.Frame(temp)

            vostfr = ttk.Button(btn,
                                text="VOSTFR",
                                command=lambda a=episode: self.open_episode(
                                    "vostfr", a["episode_id"], max_ep))
            vostfr.pack(side=LEFT, padx=10)

            mal = ttk.Button(
                btn,
                text="Lien MAL",
                command=lambda a=episode: open_url(a["video_url"]))
            mal.pack(side=LEFT, padx=10)

            vf = ttk.Button(btn,
                            text="VF",
                            command=lambda a=episode: self.open_episode(
                                "vf", a["episode_id"], max_ep))
            vf.pack(side=LEFT, padx=10)

            btn.pack(pady=5)

            temp.grid(row=i // 2, column=i % 2, pady=10, padx=5)

        for i in range(2):
            self.scroll.viewport.columnconfigure(i, weight=1)

        self.scroll.pack(pady=10)

        self.back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page("anime " + str(self.mal_id)))
        self.back.pack(pady=10)

    def open_episode(self, version, ep_id, max_ep):
        results = {
            k: v
            for k, v in self.main.streaming.provide(
                version, self.title, ep_id, max_ep).items() if v is not None
        }
        if len(results.keys()) == 0:
            messagebox.showwarning(
                "AList - Episodes",
                "Aucun lien n'a été trouvé pour cet épisode.")
        else:
            self.urls = results
            StringChooser(self, "AList - Episodes", "Choisissez la source :",
                          self.valid_episode, *results.keys())

    def valid_episode(self, choice):
        open_url(self.urls[choice])

    def next_page(self):
        if self.current_page != self.last_page:
            self.current_page += 1
            self.reload_results()

    def previous_page(self):
        if self.current_page != 1:
            self.current_page -= 1
            self.reload_results()
Exemplo n.º 14
0
    def reload_results(self):
        self.episodes = self.main.mal.anime(self.mal_id, "episodes",
                                            self.current_page)
        self.last_page = self.episodes["episodes_last_page"]
        self.num_page["text"] = "Page " + str(self.current_page) + "/" + str(
            self.last_page)

        self.scroll.destroy()
        self.back.destroy()

        self.scroll = ScrollFrame(self, width=1080, height=580)
        self.scroll.pack_propagate(False)

        if self.last_page == 1:
            max_ep = len(self.episodes["episodes"])
        else:
            max_ep = 100 * self.last_page - 1

        for i, episode in enumerate(self.episodes["episodes"]):
            date = datetime.strptime(episode["aired"],
                                     "%Y-%m-%dT%H:%M:%S+00:00")

            temp = ttk.Frame(self.scroll.viewport)

            ttitle = ttk.Label(temp,
                               text=str(episode["episode_id"]) + " - " +
                               episode["title"],
                               font="-weight bold")
            ttitle.pack(pady=10)

            infos = ttk.Frame(temp)

            date = ttk.Label(infos,
                             text="Date : " + str(date.day) + "/" +
                             str(date.month) + "/" + str(date.year))
            date.pack(side=LEFT, padx=10)
            filler = ttk.Label(infos,
                               text="Filler : " +
                               ("Oui" if episode["filler"] else "Non"))
            filler.pack(side=LEFT, padx=10)
            recap = ttk.Label(infos,
                              text="Recap : " +
                              ("Oui" if episode["recap"] else "Non"))
            recap.pack(side=LEFT, padx=10)

            infos.pack(pady=5)

            btn = ttk.Frame(temp)

            vostfr = ttk.Button(btn,
                                text="VOSTFR",
                                command=lambda a=episode: self.open_episode(
                                    "vostfr", a["episode_id"], max_ep))
            vostfr.pack(side=LEFT, padx=10)

            mal = ttk.Button(
                btn,
                text="Lien MAL",
                command=lambda a=episode: open_url(a["video_url"]))
            mal.pack(side=LEFT, padx=10)

            vf = ttk.Button(btn,
                            text="VF",
                            command=lambda a=episode: self.open_episode(
                                "vf", a["episode_id"], max_ep))
            vf.pack(side=LEFT, padx=10)

            btn.pack(pady=5)

            temp.grid(row=i // 2, column=i % 2, pady=10, padx=5)

        for i in range(2):
            self.scroll.viewport.columnconfigure(i, weight=1)

        self.scroll.pack(pady=10)

        self.back = ttk.Button(
            self,
            text="Retour",
            command=lambda: self.main.show_page("anime " + str(self.mal_id)))
        self.back.pack(pady=10)
Exemplo n.º 15
0
class Reviews(RightPage):
    def __init__(self, main, mal_id, title):
        super(Reviews, self).__init__(main)
        self.current_page = int(title[2:].split("_")[0])
        self.mal_id = mal_id
        self.reviews = None
        if title.startswith("a_"):
            self.type_ = "anime"
        else:
            self.type_ = "manga"
        title = "_".join(title[2:].split("_")[1:])

        title = ttk.Label(self, text=title, font="-size 22 -weight bold")
        title.pack(pady=15)

        bottom_frame = ttk.Frame(self)

        left_page = ttk.Button(bottom_frame,
                               text="<-",
                               width=20,
                               command=self.previous_page)
        left_page.pack(side=LEFT, padx=20)
        self.num_page = ttk.Label(bottom_frame,
                                  text="Page " + str(self.current_page))
        self.num_page.pack(side=LEFT, padx=20)
        right_page = ttk.Button(bottom_frame,
                                text="->",
                                width=20,
                                command=self.next_page)
        right_page.pack(side=LEFT, padx=20)

        bottom_frame.pack(pady=10)

        self.scroll = ScrollFrame(self, width=1080, height=600)
        self.scroll.pack_propagate(False)

        self.scroll.pack(pady=10)

        self.back = ttk.Button(self,
                               text="Retour",
                               command=lambda: self.main.show_page(
                                   self.type_ + " " + str(mal_id)))
        self.back.pack(pady=10)

        self.pack(side=RIGHT, fill=BOTH)

        self.reload_results()

    def reload_results(self):
        if self.type_ == "anime":
            self.reviews = self.main.mal.anime(self.mal_id, "reviews",
                                               self.current_page)
        else:
            self.reviews = self.main.mal.manga(self.mal_id, "reviews",
                                               self.current_page)

        self.scroll.destroy()
        self.back.destroy()

        self.scroll = ScrollFrame(self, width=1080, height=580)
        self.scroll.pack_propagate(False)

        for review in self.reviews["reviews"]:
            date = datetime.strptime(review["date"], "%Y-%m-%dT%H:%M:%S+00:00")
            temp = ttk.Frame(self.scroll.viewport)

            author = ttk.Label(temp,
                               text=review["reviewer"]["username"],
                               font="-weight bold")
            author.grid(row=0, column=0, pady=10, padx=10)
            if self.type_ == "anime":
                rv_text = "Episodes vus : " + str(
                    review["reviewer"]["episodes_seen"])
            else:
                rv_text = "Chapitres lus : " + str(
                    review["reviewer"]["chapters_read"])
            read_view = ttk.Label(temp, text=rv_text)
            read_view.grid(row=0, column=1, pady=10, padx=10)
            notes = ttk.Label(
                temp,
                text="Note : " + str(
                    round(
                        sum(v for v in review["reviewer"]["scores"].values()) /
                        len(review["reviewer"]["scores"]), 2)) + "/10")
            notes.grid(row=0, column=2, pady=10, padx=10)
            date = ttk.Label(temp,
                             text=str(date.day) + "/" + str(date.month) + "/" +
                             str(date.year))
            date.grid(row=0, column=3, pady=10, padx=10)

            content = ttk.Label(temp, text="", justify="center")
            self.main.translator.translate(content, review["content"])
            content.grid(row=1, column=0, columnspan=4, pady=10)

            url = ttk.Button(temp,
                             text="Lien",
                             command=lambda a=review: open_url(a["url"]))
            url.grid(row=2, column=0, columnspan=4, pady=10)

            for i in range(4):
                temp.columnconfigure(i, weight=1)
            for i in range(3):
                temp.rowconfigure(i, weight=1)

            temp.pack(pady=10, fill="x")

        self.scroll.pack(pady=10)

        self.back = ttk.Button(self,
                               text="Retour",
                               command=lambda: self.main.show_page(
                                   self.type_ + " " + str(self.mal_id)))
        self.back.pack(pady=10)

    def next_page(self):
        self.current_page += 1
        self.reload_results()
        self.num_page["text"] = "Page " + str(self.current_page)

    def previous_page(self):
        if self.current_page != 1:
            self.current_page -= 1
            self.reload_results()
            self.num_page["text"] = "Page " + str(self.current_page)
Exemplo n.º 16
0
    def reload_results(self):
        if self.type_ == "anime":
            self.reviews = self.main.mal.anime(self.mal_id, "reviews",
                                               self.current_page)
        else:
            self.reviews = self.main.mal.manga(self.mal_id, "reviews",
                                               self.current_page)

        self.scroll.destroy()
        self.back.destroy()

        self.scroll = ScrollFrame(self, width=1080, height=580)
        self.scroll.pack_propagate(False)

        for review in self.reviews["reviews"]:
            date = datetime.strptime(review["date"], "%Y-%m-%dT%H:%M:%S+00:00")
            temp = ttk.Frame(self.scroll.viewport)

            author = ttk.Label(temp,
                               text=review["reviewer"]["username"],
                               font="-weight bold")
            author.grid(row=0, column=0, pady=10, padx=10)
            if self.type_ == "anime":
                rv_text = "Episodes vus : " + str(
                    review["reviewer"]["episodes_seen"])
            else:
                rv_text = "Chapitres lus : " + str(
                    review["reviewer"]["chapters_read"])
            read_view = ttk.Label(temp, text=rv_text)
            read_view.grid(row=0, column=1, pady=10, padx=10)
            notes = ttk.Label(
                temp,
                text="Note : " + str(
                    round(
                        sum(v for v in review["reviewer"]["scores"].values()) /
                        len(review["reviewer"]["scores"]), 2)) + "/10")
            notes.grid(row=0, column=2, pady=10, padx=10)
            date = ttk.Label(temp,
                             text=str(date.day) + "/" + str(date.month) + "/" +
                             str(date.year))
            date.grid(row=0, column=3, pady=10, padx=10)

            content = ttk.Label(temp, text="", justify="center")
            self.main.translator.translate(content, review["content"])
            content.grid(row=1, column=0, columnspan=4, pady=10)

            url = ttk.Button(temp,
                             text="Lien",
                             command=lambda a=review: open_url(a["url"]))
            url.grid(row=2, column=0, columnspan=4, pady=10)

            for i in range(4):
                temp.columnconfigure(i, weight=1)
            for i in range(3):
                temp.rowconfigure(i, weight=1)

            temp.pack(pady=10, fill="x")

        self.scroll.pack(pady=10)

        self.back = ttk.Button(self,
                               text="Retour",
                               command=lambda: self.main.show_page(
                                   self.type_ + " " + str(self.mal_id)))
        self.back.pack(pady=10)
Exemplo n.º 17
0
class MyManga(RightPage):
    def __init__(self, main):
        super(MyManga, self).__init__(main)
        title = ttk.Label(self,
                          text="Mes Mangas",
                          font="-size 22 -weight bold")
        title.pack(pady=15)

        top_frame = ttk.Frame(self)

        self.search = StringVar(self)
        search_entry = ttk.Entry(top_frame, textvariable=self.search, width=30)
        search_entry.bind("<Return>", self.validate_search)
        search_entry.pack(side=LEFT, padx=30)

        self.etat = StringVar(self)
        self.etat.set("Tous")
        etat_select = ttk.OptionMenu(top_frame, self.etat, "Tous", "Tous",
                                     "A voir", "En visionnement", "Fini",
                                     "Abandonné")
        etat_select["width"] = 30
        etat_select.pack(side=LEFT, padx=30)

        top_frame.pack(pady=10)

        bottom_frame = ttk.Frame(self)

        self.exp_imp = StringVar(self)
        self.exp_imp.set("MyAnimeList")
        exp_imp = ttk.OptionMenu(bottom_frame, self.exp_imp, "MyAnimeList")
        exp_imp["width"] = 30
        exp_imp.pack(side=LEFT, padx=20)
        import_ = ttk.Button(bottom_frame,
                             text="Import",
                             width=20,
                             command=self.import_)
        import_.pack(side=LEFT, padx=10)
        export = ttk.Button(bottom_frame,
                            text="Export",
                            width=20,
                            command=self.export_)
        export.pack(side=LEFT, padx=10)

        bottom_frame.pack(pady=10)

        self.result_frame = ScrollFrame(self, width=1080, height=800)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)
        self.result_frame.pack(pady=(10, 0))

        self.validate_state()

        self.pack(side=RIGHT, fill=BOTH)

        self.etat.trace("w", self.validate_state)
        self.validate_state()

    def import_(self):
        if self.exp_imp.get() == "MyAnimeList":
            file = filedialog.askopenfilename(parent=self,
                                              title="AList - Import MAL",
                                              filetypes=(("Fichier MAL",
                                                          ".xml"), ),
                                              multiple=False)
            if file:
                self.main.mal_import.import_("manga", file)
                self.main.show_page("reload")

    def export_(self):
        if self.exp_imp.get() == "MyAnimeList":
            file = filedialog.asksaveasfilename(parent=self,
                                                title="AList - Export MAL",
                                                filetypes=(("Fichier MAL",
                                                            ".xml"), ))
            if file:
                self.main.mal_export.export("manga", file)

    def validate_search(self, *ignore):
        self.reload_results(self.main.mymanga.search(self.search.get()))

    def validate_state(self, *ignore):
        if self.etat.get() == "Tous":
            self.reload_results(self.main.mymanga.get_all())
        else:
            self.reload_results(
                self.main.mymanga.get_all_state(self.etat.get()))

    def reload_results(self, results):
        self.result_frame.destroy()

        self.result_frame = ScrollFrame(self, width=1080, height=800)
        self.result_frame.pack_propagate(False)
        self.result_frame.grid_propagate(False)

        for i, manga in enumerate(results):
            temp = ttk.Frame(self.result_frame.viewport, relief=SUNKEN)
            temp.pack_propagate(False)
            temp.config(width=400, height=220)

            title = ttk.Label(temp, text=manga["name"], font="-size 13")
            title.pack(pady=10)
            status = ttk.Label(temp, text="Statut : " + manga["status"])
            status.pack(pady=5)
            ep = ttk.Label(temp,
                           text="Volumes : " + str(manga["vol"]) + "/" +
                           str(manga["max_vol"]))
            ep.pack(pady=5)
            ep = ttk.Label(temp,
                           text="Chapitres : " + str(manga["chap"]) + "/" +
                           str(manga["max_chap"]))
            ep.pack(pady=5)

            buttons = ttk.Frame(temp)

            delete = ttk.Button(
                buttons,
                text="Supprimer",
                width=10,
                command=lambda a=manga: self.delete_manga(a["id"]))
            delete.pack(side=LEFT, padx=10)
            more_info = ttk.Button(buttons,
                                   text="Plus d'info",
                                   command=lambda a=manga: self.main.show_page(
                                       "manga " + str(a["id"])))
            more_info.pack(side=RIGHT, padx=10)
            modify = ttk.Button(buttons,
                                text="Modifier",
                                command=lambda a=manga: self.main.show_page(
                                    "modifmanga " + str(a["id"])))
            modify.pack(padx=10)

            buttons.pack(pady=(15, 3))

            buttons2 = ttk.Frame(temp)
            down_vol = ttk.Button(buttons2,
                                  text="-1 Vol",
                                  width=8,
                                  command=lambda a=manga: self.modify_vol_chap(
                                      a, "vol", a["vol"] - 1))
            down_vol.pack(side=LEFT, padx=10)
            down_chap = ttk.Button(buttons2,
                                   text="-1 Chap",
                                   width=8,
                                   command=lambda a=manga: self.
                                   modify_vol_chap(a, "chap", a["chap"] - 1))
            down_chap.pack(side=LEFT, padx=10)
            up_vol = ttk.Button(buttons2,
                                text="+1 Vol",
                                width=8,
                                command=lambda a=manga: self.modify_vol_chap(
                                    a, "vol", a["vol"] + 1))
            up_vol.pack(side=RIGHT, padx=10)
            up_chap = ttk.Button(buttons2,
                                 text="+1 Chap",
                                 width=8,
                                 command=lambda a=manga: self.modify_vol_chap(
                                     a, "chap", a["chap"] + 1))
            up_chap.pack(side=RIGHT, padx=10)
            buttons2.pack(pady=(3, 15))

            temp.grid(row=i // 2, column=i % 2, pady=20)

        self.result_frame.viewport.columnconfigure(0, weight=1)
        self.result_frame.viewport.columnconfigure(1, weight=1)
        self.result_frame.pack(pady=(10, 0))

    def modify_vol_chap(self, manga, type_, nb):
        if nb > manga["max_" + type_]:
            eval("self.main.mymanga.modify(manga[\"id\"], " + type_ +
                 "=manga[\"max_\"" + type_ + "])")
        elif nb < 0:
            eval("self.main.mymanga.modify(manga[\"id\"], " + type_ + "=0)")
        else:
            eval("self.main.mymanga.modify(manga[\"id\"], " + type_ + "=nb)")
        self.main.show_page("reload")

    def delete_manga(self, mal_id):
        self.main.mymanga.delete(mal_id)
        self.main.show_page("reload")