Code: Select all
; Set the path to your TV shows folder
TVShowsFolder := "F:\"
; Set the list of supported video file extensions
VideoExtensions := [".avi", ".mp4", ".mkv", ".mov", ".wmv"]
; Set the path to PotPlayer
PotPlayerPath := "C:\PortableApps\PotPlayerPortable\App\PotPlayer\PotPlayerMini.exe"
; Get the list of TV shows in the folder
TVShowsList := []
Loop, Files, % TVShowsFolder . "\*", D
TVShowsList.Push(A_LoopFileName)
; Shuffle the list of TV shows
Random, rand, 1, TVShowsList.MaxIndex()
TVShowsList.Swap(1, rand)
; Create an object to keep track of played episodes for each show
PlayedEpisodes := {}
for index, show in TVShowsList
PlayedEpisodes[show] := []
; Function to get the next unplayed episode for a given show
GetNextUnplayedEpisode(show) {
; Get the list of episodes for the given show
EpisodesList := []
Loop, Files, % TVShowsFolder . "\" . show . "\*", F
if (VideoExtensions.HasKey(SubStr(A_LoopFileName, InStr(A_LoopFileName, ".", 0))))
EpisodesList.Push(A_LoopFileName)
; Find the first unplayed episode
for index, episode in EpisodesList
if (!PlayedEpisodes[show].HasKey(episode))
return episode
; If all episodes have been played, return an empty string
return ""
}
; Play one episode from each show before playing a second episode from the same show
for index, show in TVShowsList {
; Get the next unplayed episode for this show
NextEpisode := GetNextUnplayedEpisode(show)
; If there is an unplayed episode, play it and add it to the list of played episodes
if (NextEpisode != "") {
RunWait, % PotPlayerPath . " " . TVShowsFolder . "\" . show . "\" . NextEpisode
PlayedEpisodes[show].Push(NextEpisode)
}
}
Currently, nothing happens when I try opening my script