Can't get my script to work

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
thebib622
Posts: 25
Joined: 01 Aug 2017, 17:09

Can't get my script to work

Post by thebib622 » 29 May 2023, 22:37

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)
    }
}
Hello, I was hoping for some help. The script is meant to shuffle my TV shows, and to ensure only 1 episode from each series is played before the script plays a second episode from a show. Also, the next file should open only after potplayer is closed.

Currently, nothing happens when I try opening my script

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Can't get my script to work

Post by boiler » 30 May 2023, 00:25

Clearly you didn’t write this script. No one writes a script of this complexity completely before running it and then their only conclusion is “nothing happens.” You would say, I have this part working, but I can’t get this new part to work, etc. So it was generated by ChatGPT, right?

thebib622
Posts: 25
Joined: 01 Aug 2017, 17:09

Re: Can't get my script to work

Post by thebib622 » 30 May 2023, 10:03

Yes that's right.

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Can't get my script to work

Post by boiler » 30 May 2023, 10:30

Thanks for clarifying that. Asking for help with ChatGPT-generated scripts is against the Forum Rules since ChatGPT produces bad code and very often nonsensical code, and unraveling it is a waste of the forum members' time.

This thread is locked. You can start a new thread asking for help on specific questions you may have.

Locked

Return to “Ask for Help (v2)”