From 73971ba68a6dc7fa7cb0e3a137e50d902882b63b Mon Sep 17 00:00:00 2001 From: bontoutou00 <107948159+bontoutou00@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:23:57 +0100 Subject: [PATCH 1/5] MyDramaList fix and others fixes --- topic_maker/main.py | 169 +++++++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 63 deletions(-) diff --git a/topic_maker/main.py b/topic_maker/main.py index e1eddd9..ddc937b 100644 --- a/topic_maker/main.py +++ b/topic_maker/main.py @@ -230,49 +230,84 @@ def omdb_results(self): The user can select one of the results and double-click on it to choose it. """ self.omdb_results_ = tk.Toplevel(self) - self.omdb_results_.title("Search Results") + self.omdb_results_.title("OMDB Search Results") self.omdb_results_.geometry("650x290") self.waiting_var = tk.IntVar() self.imdb_id_search = tk.StringVar() columns = ('title', 'year', 'mediatype') - self.tree = ttk.Treeview(self.omdb_results_, columns=columns, show='headings') - self.tree.heading('title', text='Title') - self.tree.column('title', width=300, anchor=tk.W) - self.tree.heading('year', text='Year') - self.tree.column('year', width=50, anchor=tk.W) - self.tree.heading('mediatype', text='Mediatype') - self.tree.column('mediatype', width=50, anchor=tk.W) - self.tree.bind('<>', self.result_selected) - self.tree.bind('', self.choice_result) - self.tree.place(x=10.0, y=10.0, width=630, height=270) + self.tree_omdb = ttk.Treeview(self.omdb_results_, columns=columns, show='headings') + self.tree_omdb.heading('title', text='Title') + self.tree_omdb.column('title', width=300, anchor=tk.W) + self.tree_omdb.heading('year', text='Year') + self.tree_omdb.column('year', width=50, anchor=tk.W) + self.tree_omdb.heading('mediatype', text='Mediatype') + self.tree_omdb.column('mediatype', width=50, anchor=tk.W) + self.tree_omdb.bind('<>', + lambda event: self.result_selected(search='omdb', tree=self.tree_omdb, event=event)) + self.tree_omdb.bind('', + lambda event: self.choice_result(search='omdb', tree=self.tree_omdb, event=event)) + self.tree_omdb.place(x=10.0, y=10.0, width=630, height=270) self.omdb_results_.resizable(False, False) - def choice_result(self, event): + def mdl_results(self): + """ + The omdb_results function creates a new window that displays the results of an OMDB search.\n + The user can select one of the results and double-click on it to choose it. + """ + self.mdl_results_ = tk.Toplevel(self) + self.mdl_results_.title("MyDramaList Search Results") + self.mdl_results_.geometry("650x290") + self.waiting_var = tk.IntVar() + self.mdl_search = tk.StringVar() + columns = ('title', 'mediatype') + self.tree_mdl = ttk.Treeview(self.mdl_results_, columns=columns, show='headings') + self.tree_mdl.heading('title', text='Title') + self.tree_mdl.column('title', width=300, anchor=tk.W) + self.tree_mdl.heading('mediatype', text='Mediatype') + self.tree_mdl.column('mediatype', width=50, anchor=tk.W) + self.tree_mdl.bind('<>', + lambda event: self.result_selected(search='mdl', tree=self.tree_mdl, event=event)) + self.tree_mdl.bind('', + lambda event: self.choice_result(search='mdl', tree=self.tree_mdl, event=event)) + self.tree_mdl.place(x=10.0, y=10.0, width=630, height=270) + self.mdl_results_.resizable(False, False) + + def choice_result(self, search, tree, event): """ The choice_result function is called when the user clicks on a row in the omdb_results window.\n It takes the imdbID of that movie and puts it into self.imdb_id_search,\n which is then used to search for the movie in question. """ - for selected_item in self.tree.selection(): - item = self.tree.item(selected_item) + for selected_item in tree.selection(): + item = tree.item(selected_item) record = item['values'] - self.imdb_id_search.set(record[3]) - self.destroy_window(self.omdb_results_) + if search == 'omdb': + self.imdb_id_search.set(record[3]) + self.destroy_window(self.omdb_results_) + else: + self.mdl_search.set(record[0]) + self.destroy_window(self.mdl_results_) - def result_selected(self, event): + def result_selected(self, search, tree, event): """ The result_selected function is called when the user right-clicks on a row in the treeview.\n It creates a context menu with two options: Copy Link and Open iMDB link. The first option copies\n the IMDb URL of the selected movie to clipboard, while the second opens it in your default browser. """ - for selected_item in self.tree.selection(): - item = self.tree.item(selected_item) + for selected_item in tree.selection(): + item = tree.item(selected_item) record = item['values'] if record: - context_menu = tk.Menu(gui.omdb_results_, tearoff=0) - context_menu.add_command(label="Copy Link", command=lambda: copy(f'https://www.imdb.com/title/{record[3]}')) - context_menu.add_command(label="Open iMDB link", command = lambda: webbrowser.open_new_tab(f'https://www.imdb.com/title/{record[3]}')) - self.tree.bind("", lambda event: context_menu.post(event.x_root, event.y_root)) + if search == 'omdb': + context_menu = tk.Menu(gui.omdb_results_, tearoff=0) + context_menu.add_command(label="Copy Link", command=lambda: copy(f'https://www.imdb.com/title/{record[3]}')) + context_menu.add_command(label="Open iMDB Link", command = lambda: webbrowser.open_new_tab(f'https://www.imdb.com/title/{record[3]}')) + tree.bind("", lambda event: context_menu.post(event.x_root, event.y_root)) + else: + context_menu = tk.Menu(gui.mdl_results_, tearoff=0) + context_menu.add_command(label="Copy Link", command=lambda: copy(record[2])) + context_menu.add_command(label="Open MyDramaList Link", command = lambda: webbrowser.open_new_tab(record[2])) + tree.bind("", lambda event: context_menu.post(event.x_root, event.y_root)) def destroy_window(self, window): """ @@ -392,7 +427,7 @@ def omdb_handling(self): gui.save_config_settings('omdb') omdb_api = Config().config.get("SETTINGS", "omdb_api") self.omdb_client = Client(omdb_api) - self.name = gui.entry_name.get() + self.name = gui.entry_name.get().strip() imdb_entry = re.search(r'(tt\d{1,})', self.name) if self.name == 'Movie or TV Name': sys.exit() @@ -458,7 +493,7 @@ def imdb_search_list(self): self.search_results.append({'title': value['Title'], 'year': value['Year'], 'mediatype': value['Type'], 'imdb_id': value['imdbID']}) gui.omdb_results() for result in self.search_results: - gui.tree.insert('', tk.END, values=list(result.values())) + gui.tree_omdb.insert('', tk.END, values=list(result.values())) gui.wait_variable(gui.waiting_var) gui.entry_name.delete(0, tk.END) gui.entry_name.insert(tk.END, gui.imdb_id_search.get()) @@ -491,40 +526,55 @@ def set_entries(self): gui.entry_year.delete(0, tk.END) gui.entry_name.insert(tk.END, self.name) gui.entry_year.insert(tk.END, self.year) + self.mdl() def mdl(self): """ - The mdl function searches MyDramaList for the title and year of the movie / drama.\n - If a match is found, it returns True and populates self.data_mdl. + The mdl function searches MyDramaList for the title and year of the movie / drama. """ - try: - req = PyMDL.search(name=self.name, year=self.year) - logger.info(f'MyDramaList results: {req}') - mdl_dic = req.get(0) - except AttributeError: - return False - else: - self.data_mdl = { - 'title_mdl' : mdl_dic.title, - 'thumbnail_mdl' : mdl_dic.thumbnail, - 'media_type_mdl' : mdl_dic.type, - 'url_mdl' : mdl_dic.url, - 'ratings_mdl' : mdl_dic.ratings, - 'plot_mdl' : mdl_dic.synopsis, - 'actors_mdl' : ",".join(mdl_dic.casts), - 'native_title_mdl' : mdl_dic.native, - 'genre_mdl' : mdl_dic.genre, - 'runtime_mdl' : mdl_dic.duration, - 'country_mdl' : mdl_dic.country, - 'aka_mdl' : ",".join(mdl_dic.aka), - 'director_mdl' : mdl_dic.director, - 'writer_mdl' : mdl_dic.screenwriter, - 'release_date_mdl' : mdl_dic.date, - #'recommendations_mdl' : ",".join(mdl_dic.reco), - #'reviews_mdl' : ",".join(mdl_dic.reviews) - } - logger.info(self.data_mdl) - return True + if gui.mdl_var.get() is True: + try: + mdl_year = re.search(r'(\d{4})', self.year).group(1) + self.search_results.clear() + resp = PyMDL.search(name=self.name, year=mdl_year, max_results=5) + logger.info(f'MyDramaList results: {resp}') + except AttributeError: + return False + else: + if resp is not None: + for value in resp.get_all(): + self.search_results.append({'title': value.title, 'mediatype': value.type, 'link': value.url}) + gui.mdl_results() + for result in self.search_results: + gui.tree_mdl.insert('', tk.END, values=list(result.values())) + gui.wait_variable(gui.waiting_var) + try: + resp = PyMDL.search(name=gui.mdl_search.get()) + mdl_dic = resp.get(0) + except AttributeError: + return False + else: + data_mdl = { + 'title_mdl' : mdl_dic.title, + 'thumbnail_mdl' : mdl_dic.thumbnail, + 'media_type_mdl' : mdl_dic.type, + 'url_mdl' : mdl_dic.url, + 'ratings_mdl' : mdl_dic.ratings, + 'plot_mdl' : mdl_dic.synopsis, + 'actors_mdl' : ",".join(mdl_dic.casts), + 'native_title_mdl' : mdl_dic.native, + 'genre_mdl' : mdl_dic.genre, + 'runtime_mdl' : mdl_dic.duration, + 'country_mdl' : mdl_dic.country, + 'aka_mdl' : ",".join(mdl_dic.aka), + 'director_mdl' : mdl_dic.director, + 'writer_mdl' : mdl_dic.screenwriter, + 'release_date_mdl' : mdl_dic.date, + } + logger.info(data_mdl) + self.data.update(data_mdl) + else: + self.alert('Error', f'No results for {self.name} ({mdl_year})', 'error') def media_info(self): """ @@ -608,11 +658,7 @@ def imgbb_screenshot(self): path_without_extension = ".".join(self.file_path.split(".")[:-1]) output_join = f'{path_without_extension}-%03d.png' try: - output = subprocess.Popen("ffmpeg -ss 00:02:00 -i "+ - "\"" + str(self.file_path) + - "\"" + " -vf fps=1/60 -frames:v " + number + - " -f image2 " + - "\"" + output_join + "\"", + output = subprocess.Popen(f'ffmpeg -ss 00:02:00 -i "{str(self.file_path)}" -vf fps=1/60 -frames:v {number} -f image2 "{output_join}"', stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=1) @@ -722,9 +768,6 @@ def template_maker(self): if gui.screenshoots_var.get() is True: screenshots_links = self.imgbb_screenshot() self.data.update({'screenshots': ("".join(screenshots_links) +'\n')}) - if gui.mdl_var.get() is True: - if self.mdl() is True: - self.data.update(self.data_mdl) imdb_template_res = Templates().complete_template(self.data) with open(f"{name}.txt", 'w', encoding="utf8") as file: file.write(imdb_template_res) From cdcc77eb966b0d1886a9f651dc49d98554c8053c Mon Sep 17 00:00:00 2001 From: bontoutou00 <107948159+bontoutou00@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:24:09 +0100 Subject: [PATCH 2/5] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1462eff..f0343a2 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ or return None if not found | $thumbnail_mdl | A link to the thumbnail. | $media_type_mdl | Drama or movie. | $url_mdl | The url that was used for scraping the data. -| $ratings_mdl | Rating of the movie.. +| $ratings_mdl | Rating of the movie. | $plot_mdl | Short plot of the movie / drama. | $casts_mdl | Actors playing in the movie / drama. | $native_title_mdl | Native language title. From 36e8e937ac9dde08a064bb9d443382c573c2c5fc Mon Sep 17 00:00:00 2001 From: bontoutou00 <107948159+bontoutou00@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:25:44 +0100 Subject: [PATCH 3/5] Examples of template --- .../Template examples/imdb + MyDramaList.txt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 topic_maker/Template examples/imdb + MyDramaList.txt diff --git a/topic_maker/Template examples/imdb + MyDramaList.txt b/topic_maker/Template examples/imdb + MyDramaList.txt new file mode 100644 index 0000000..7495ec5 --- /dev/null +++ b/topic_maker/Template examples/imdb + MyDramaList.txt @@ -0,0 +1,50 @@ +[imdb]{ + "poster": "$poster", + "title": "$title", + "year": "$year", + "directors": "$director", + "stars": "$actors", + "ratings": "$imdbrating", + "votes": "$imdbvotes", + "runTime": "$runtime", + "summary": "$plot_full", + "shortSummary": "$plot_short", + "genre": "$genre", + "releaseDate": "$released", + "viewerRating": "$rated", + "language": "$language", + "imdbId": "$imdbid", + "mediaType": "$type" +}[/imdb] + +[center][size=200][b][url=$url_mdl]$title_mdl[/url] [/b][/size][/center] + + + +[center][color=#FF8000][b][size=120]$ratings_mdl/10[/size][/b][/color][/center] + + + +[center][b][size=120]$genre_mdl[/size][/b][/center] + + + +[quote][center]$plot_mdl[/center][/quote] + + +[color=#FF8000][b]Title[/b][/color]: $title_mdl +[color=#FF8000][b]Original Title[/b][/color]: $native_title_mdl +[color=#FF8000][b]Also Known As[/b][/color]: $aka_mdl + +[color=#FF8000][b]Type[/b][/color]: $media_type_mdl +[color=#FF8000][b]Language[/b][/color]: $language +[color=#FF8000][b]Runtime[/b][/color]: $runtime_mdl + +[color=#FF8000][b]Country[/b][/color]: $country_mdl +[color=#FF8000][b]Genres[/b][/color]: $genre_mdl + +[color=#FF0000]$link_provider (use [url=https://www.base64decode.org/]base64decode[/url]) DECODE TWICE! +[center][hide][b][url=$link][size=200]$link_provider[/color][/url][/b][/hide][/size][/center] + + +[mediainfo]$mediainfo[/mediainfo] From 852ac14ef9685c06466874a7dbf70e107adfe7bc Mon Sep 17 00:00:00 2001 From: bontoutou00 <107948159+bontoutou00@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:32:50 +0100 Subject: [PATCH 4/5] v1.0.1 --- topic_maker/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topic_maker/constants.py b/topic_maker/constants.py index 6600ade..ebfdb12 100644 --- a/topic_maker/constants.py +++ b/topic_maker/constants.py @@ -72,4 +72,4 @@ 'Screenshots': '$screenshots', } -VERSION = 'v1.0.0' +VERSION = 'v1.0.1' From bdcc00e71da3a6edc1349d38228176c2e841b9a8 Mon Sep 17 00:00:00 2001 From: bontoutou00 <107948159+bontoutou00@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:42:03 +0100 Subject: [PATCH 5/5] Updated Virus Total link --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f0343a2..6bb393c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Easily create a topic with iMDB/MyDramaList infos using a template - Fill the 'Movie or TV Name' with your wanted search (It can be a movie / tv name but also a iMDB ID) - If you didn't search for an iMDB ID, it will show a window with the search results - Double click on your prefered result to continue +- If you check for MyDramaList, you will get another search results window based on the iMDB title / year - It will now ask for a file to get the mediainfo - It will produces a new txt file with the topic created @@ -192,7 +193,7 @@ pip install pyinstaller\dist\pyinstaller-5.8.0.tar.gz Command used to compile the executable: ``` -pyinstaller --clean --noconfirm --onefile --windowed --name "Topic Maker v1.0.0" --icon "topic_maker/favicon.ico" --add-data "topic_maker/config.py;." --add-data "topic_maker/constants.py;." --add-data "topic_maker/exceptions.py;." --add-data "topic_maker/omdb_api_fetcher.py;." --add-data "topic_maker/template.py;." --add-data "topic_maker/favicon.ico;." --collect-data "sv_ttk" "topic_maker/main.py" +pyinstaller --clean --noconfirm --onefile --windowed --name "Topic Maker v1.0.1" --icon "topic_maker/favicon.ico" --add-data "topic_maker/config.py;." --add-data "topic_maker/constants.py;." --add-data "topic_maker/exceptions.py;." --add-data "topic_maker/omdb_api_fetcher.py;." --add-data "topic_maker/template.py;." --add-data "topic_maker/favicon.ico;." --collect-data "sv_ttk" "topic_maker/main.py" ``` ## Created using * [Python](https://www.python.org/) @@ -206,13 +207,13 @@ pyinstaller --clean --noconfirm --onefile --windowed --name "Topic Maker v1.0.0" * [Icon created by Yogi Aprelliyanto](https://www.flaticon.com/free-icon/browser_9892390) ## Virus Scan -[Virus Total](https://www.virustotal.com/gui/file/36b6d6e7ddc9f1b748b23133f7aec4802460fd413a1e6f1f8747e9b3fd04e656) - 4/69 detected +[Virus Total](https://www.virustotal.com/gui/file/53784e7746485103169e8182ebe59427d30a99baf9c6c6eb549d68040d35ff6d) - 4/69 detected All positives detections are false (You can inspect the source code or compile it yourself) The executable is created with Pyinstaller 5.8.0 with Python 3.11.2 (Bootloader compiled every release inside a VM, compiled because of the highest numbers of false positives in the release one) -MD5: 209b81ade42eca4cf06c1bbdf0cf8b1a +MD5: b8bf08403ff0606cf8ce0edaebb16e32 -SHA-256: 36b6d6e7ddc9f1b748b23133f7aec4802460fd413a1e6f1f8747e9b3fd04e656 +SHA-256: 53784e7746485103169e8182ebe59427d30a99baf9c6c6eb549d68040d35ff6d