Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from bontoutou00/develop
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
bontoutou00 committed Mar 15, 2023
2 parents 9c102b5 + bdcc00e commit bc485e3
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 69 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -54,7 +55,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.
Expand Down Expand Up @@ -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/)
Expand All @@ -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
50 changes: 50 additions & 0 deletions topic_maker/Template examples/imdb + MyDramaList.txt
Original file line number Diff line number Diff line change
@@ -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]
2 changes: 1 addition & 1 deletion topic_maker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
'Screenshots': '$screenshots',
}

VERSION = 'v1.0.0'
VERSION = 'v1.0.1'
169 changes: 106 additions & 63 deletions topic_maker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<<TreeviewSelect>>', self.result_selected)
self.tree.bind('<Double-Button>', 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('<<TreeviewSelect>>',
lambda event: self.result_selected(search='omdb', tree=self.tree_omdb, event=event))
self.tree_omdb.bind('<Double-Button>',
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('<<TreeviewSelect>>',
lambda event: self.result_selected(search='mdl', tree=self.tree_mdl, event=event))
self.tree_mdl.bind('<Double-Button>',
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("<Button-3>", 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("<Button-3>", 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("<Button-3>", lambda event: context_menu.post(event.x_root, event.y_root))

def destroy_window(self, window):
"""
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bc485e3

Please sign in to comment.