Skip to content

Commit

Permalink
Added additional players, fixed launching of some players with broken…
Browse files Browse the repository at this point in the history
… resume options. Clarified variable names. Added comments
  • Loading branch information
JuiceyBoost committed Aug 28, 2024
1 parent b6b0bfc commit 1df4b08
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.spec
dist/
build/
58 changes: 44 additions & 14 deletions emby_player_picker_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ def detect_media_players():
if os.path.exists(potplayer_path):
players.append(('PotPlayer', potplayer_path))

# Check for LAV Filter Megamix MPC and PotPlayer
lav_mpc_x64_path = "C:\\Program Files (x86)\\LAV Filters\\x64\\mpc-hc\\shoukaku.exe"
if os.path.exists(lav_mpc_x64_path):
players.append(('LAV Megamix MPC-HC (x64)', lav_mpc_x64_path))

lav_mpc_x32_path = "C:\\Program Files (x86)\\LAV Filters\\x32\\mpc-hc\\shoukaku.exe"
if os.path.exists(lav_mpc_x32_path):
players.append(('LAV Megamix MPC-HC (x32)', lav_mpc_x32_path))

lav_potplayer_x64_path = "C:\\Program Files (x86)\\LAV Filters\\x64\\PotPlayer\\zuikaku.exe"
if os.path.exists(lav_potplayer_x64_path):
players.append(('LAV Megamix PotPlayer (x64)', lav_potplayer_x64_path))

lav_potplayer_x32_path = "C:\\Program Files (x86)\\LAV Filters\\x32\\PotPlayer\\zuikaku.exe"
if os.path.exists(lav_potplayer_x32_path):
players.append(('LAV Megamix PotPlayer (x32)', lav_potplayer_x32_path))

# Check for ACG Player
acgplayer_path = "C:\\Program Files\\WindowsApps\\ACGPlayer\\ACGPlayer.exe"
if os.path.exists(acgplayer_path):
Expand Down Expand Up @@ -116,8 +133,11 @@ def main():
print("Error: First and second arguments are required.")
sys.exit(1)

arg1 = sys.argv[1]
arg2 = sys.argv[2]
media_url = sys.argv[1] # HLS Stream URL from Emby/Jellyfin
seconds = sys.argv[2] # Resume time measured in Seconds

# Convert Seconds into milliseconds for relevant players
milliseconds = int(seconds) * 1000

# Detect available media players
players = detect_media_players()
Expand All @@ -141,24 +161,34 @@ def main():

player_name, player_path = players[choice_idx]

print(f"\nOpening {player_name} with arguments: {arg1}")
print(f"\nOpening {player_name}")


# Build command and arguments based on the chosen player
if 'MPV' in player_name:
subprocess.Popen([player_path, f"--start={arg2}", arg1])
print(f"\nOpening: {player_path} --start={seconds} {media_url}")
subprocess.Popen([player_path, f"--start={seconds}", media_url])

elif player_name == 'VLC':
subprocess.Popen([player_path, arg1, f"--start-time={arg2}"])
elif 'MPC' in player_name:
milliseconds = int(arg2 * 1000)
subprocess.Popen([player_path, arg1, f"/start {milliseconds}"])
elif player_name == 'PotPlayer':
subprocess.Popen([player_path, arg1, f"/seek={arg2}"])
print(f"\nOpening: {player_path} {media_url} --start-time={seconds}")
subprocess.Popen([player_path, media_url, f"--start-time={seconds}"])

elif 'PotPlayer' in player_name:
print(f"\nOpening: {player_path} {media_url} /seek {seconds}")
subprocess.Popen([player_path, media_url, f"/seek={seconds}"])

elif player_name == 'SMPlayer':
subprocess.Popen([player_path, f"--start={arg2}", arg1])
elif player_name == 'Zoom Player':
subprocess.Popen([player_path, arg1, f"/seek:{arg2}"])
print(f"\nOpening: {player_path} --start={seconds} {media_url}")
subprocess.Popen([player_path, f"--start={seconds}", media_url])

#Disabled MPC custom arguments for now as adding arguments beyond media_url causes "unknown switches" error in MPC
#elif 'MPC' in player_name:
# print(f"\nOpening: {player_path} {media_url} /start {milliseconds}")
# subprocess.Popen([player_path, f'"{media_url}"', f"/start {seconds}"])

else:
subprocess.Popen([player_path, arg1])
print(f"\nOpening: {player_path} {media_url}")
subprocess.Popen([player_path, media_url])

except ValueError:
print("\nInvalid choice. Please select a valid option.")
Expand Down
4 changes: 2 additions & 2 deletions launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
sys.exit(1)

# Retrieve the arguments
arg1 = sys.argv[1]
arg2 = sys.argv[2]
arg1 = sys.argv[1] # HLS Stream URL from Emby/Jellyfin
arg2 = sys.argv[2] # Resume time measured in Seconds

# Print the arguments for debugging purposes
print(f"Arguments received:\narg1: {arg1}\narg2: {arg2}")
Expand Down

0 comments on commit 1df4b08

Please sign in to comment.