Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
增加了播放按钮,及D:\cprogram\Green\1.Media\mpvnet\mpvnet.exe播放器关联
  • Loading branch information
cgkings committed Jun 30, 2024
1 parent 30f9f88 commit 7bea7fa
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion NFO.Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime
import xml.dom.minidom as minidom
from PIL import Image, ImageTk
import subprocess

class NFOEditorApp:
def __init__(self, root):
Expand All @@ -30,6 +31,9 @@ def __init__(self, root):
open_folder_button = tk.Button(top_frame, text="📁", command=self.open_selected_folder)
open_folder_button.pack(side=tk.LEFT, padx=5)

open_video_button = tk.Button(top_frame, text="▶", command=self.open_selected_video)
open_video_button.pack(side=tk.LEFT, padx=5)

self.folder_path_label = tk.Label(top_frame, text="")
self.folder_path_label.pack(side=tk.RIGHT, padx=5)

Expand Down Expand Up @@ -235,6 +239,26 @@ def open_selected_folder(self):
else:
messagebox.showerror("Error", f"NFO file does not exist: {nfo_file_path}")

def open_selected_video(self):
video_extensions = ['.mp4', '.mkv', '.avi', '.mov'] # Add other video formats if needed
player_path = r'D:\cprogram\Green\1.Media\mpvnet\mpvnet.exe'
player_options = '--fs=yes'

selected_indices = self.file_listbox.curselection()
if selected_indices:
selected_index = selected_indices[0]
nfo_file_path = os.path.join(self.folder_path, self.file_listbox.get(selected_index))
if os.path.exists(nfo_file_path):
video_file_base = os.path.splitext(nfo_file_path)[0]
for ext in video_extensions:
video_file = video_file_base + ext
if os.path.exists(video_file):
subprocess.run([player_path, player_options, video_file])
return
messagebox.showerror("Error", "No video file found with supported formats: .mp4, .mkv, .avi, .mov")
else:
messagebox.showerror("Error", f"NFO file does not exist: {nfo_file_path}")

def on_file_select(self, event):
selected_index = self.file_listbox.curselection()
if selected_index:
Expand Down Expand Up @@ -521,4 +545,4 @@ def apply_add():

if __name__ == "__main__":
root = tk.Tk()
app = NFOEditorApp(root)
app = NFOEditorApp(root)

0 comments on commit 7bea7fa

Please sign in to comment.