• 1
  • 57
  • 58
  • 59
  • 60(current)
  • 61
Release LazyTV - an unwatched TV Show playlist generator
(2023-01-25, 18:51)jepsizofye Wrote: https://transfer.sh/orejGe/script.lazytv...atched.zip

This link only results in 'Not Found'.  Can you please upload this again?
Reply
lets see if mediafire will last longer @DJ_Izumi

https://www.mediafire.com/file/d9zl3dfnv...d.zip/file
Reply
(2023-03-30, 21:47)jepsizofye Wrote: lets see if mediafire will last longer @DJ_Izumi

https://www.mediafire.com/file/d9zl3dfnv...d.zip/file

Thank you kindly. Smile
Reply
my pleasure
Reply
This is not me and I have not tested it yet but here is also someone that seems to be updating the plugin
https://github.com/A-Morph/lazytv

I really hope anybody will pick this up or that Kodi will get the option to build a Smart Playlist that is populated with the Next Up episodes
Reply
Hi. Where do these files actually go? I used Xplore and I thought I copied them to the right spot (I overwrote what was there), but I still get the LAzyTv error check the logs message.

I copied to:

storage/emulated/0
android/data/org.xbmc.kodi
files
Reply
You need to install it as a standalone Add-on using the zip file.
With the files here https://www.mediafire.com/file/d9zl3dfnv...d.zip/file it will create a new addon with a new name, it will not overwrite the existing orginal version
Reply
Thanks. Got it installed, however it won't let me manually select the shows I want it to populate. I get an error. Currently, it pulls every show and I want to choose. Any thoughts?
Reply
(2023-06-08, 14:24)Rouzax Wrote: This is not me and I have not tested it yet but here is also someone that seems to be updating the plugin
https://github.com/A-Morph/lazytv

I really hope anybody will pick this up or that Kodi will get the option to build a Smart Playlist that is populated with the Next Up episodes
I installed this update, and it just gives me an error when attempting to manually select either a playlist or a list of shows? 
(2023-03-30, 21:47)izprtxqkft Wrote: lets see if mediafire will last longer @DJ_Izumi

https://www.mediafire.com/file/d9zl3dfnv...d.zip/file
So... not sure if this patch would then still be working - the link is down? 

My hope is that I can finally "trick" myself into watching offbeat shows like Firefly or Twin Peaks by having them "pop up" in the midst of shows I already know I'll enjoy? ;) ie "Fine, I'll finally watch this weird show everyone's raved about forever - then right back to another episode of Deadwood. 

I seriously have absolutely no earthly idea as to WHY the good folks who authored Kodi have never seen fit to duplicate the behavior of this plugin within their playlists functionality - as MOST TV shows kinda require that they be watched in order - at least on first viewing? 

But, apparently - no one cares? ;)
Reply
(2024-01-04, 07:09)CodyLane Wrote:
(2023-06-08, 14:24)Rouzax Wrote: This is not me and I have not tested it yet but here is also someone that seems to be updating the plugin
https://github.com/A-Morph/lazytv

I really hope anybody will pick this up or that Kodi will get the option to build a Smart Playlist that is populated with the Next Up episodes
I installed this update, and it just gives me an error when attempting to manually select either a playlist or a list of shows? 
(2023-03-30, 21:47)izprtxqkft Wrote: lets see if mediafire will last longer @DJ_Izumi

https://www.mediafire.com/file/d9zl3dfnv...d.zip/file
So... not sure if this patch would then still be working - the link is down? 

My hope is that I can finally "trick" myself into watching offbeat shows like Firefly or Twin Peaks by having them "pop up" in the midst of shows I already know I'll enjoy? Wink ie "Fine, I'll finally watch this weird show everyone's raved about forever - then right back to another episode of Deadwood. 

I seriously have absolutely no earthly idea as to WHY the good folks who authored Kodi have never seen fit to duplicate the behavior of this plugin within their playlists functionality - as MOST TV shows kinda require that they be watched in order - at least on first viewing? 

But, apparently - no one cares? Wink

I fully agree, but it also looks like the popularity of Kodi is winding down in this age of streaming.
Just looking at the forums the activity is way down over years ago.

I should have a working zip file at home, when I'm back I'll load that in GitHub so it stays up.
Will be somewhere next week.
Reply
(2024-01-04, 08:51)Rouzax Wrote: I fully agree, but it also looks like the popularity of Kodi is winding down in this age of streaming.
Just looking at the forums the activity is way down over years ago.

I should have a working zip file at home, when I'm back I'll load that in GitHub so it stays up.
Will be somewhere next week.
Thank you VERY much! 

Really sucks that interest in Kodi is waning. I wonder if it might be a better idea to just "go back" a few versions? I originally started out with 17. Only reason I updated was because I know nothing about how any of this works - so I'm always guessing the newest is best? 

However, losing MAJOR functionality with the loss of addons really sucks. Also, another guru pointed out that Kodi lost its Android group, and I use Kodi solely on that platform - so that's not good. 

Ah well... I am SO INSANELY THANKFUL to the Kodi developers for what they've provided me - so very much hoping things turn back around. 

Possibly I'm paranoid, but I like having my birds in hand. And Kodi is still king when it comes to managing my own catalog.
Reply
If you aren't afraid of Powershell, this is a script I was using / working on for several years because it allowed much finer control over channel playback and commercials/bumpers/etc. than either PseudoTV or LazyTV did. It will essentially perform the functions of LazyTV by generating nodes which link to playlists. I had the script run every half hour to simulate a moving live broadcast (more or less), but if you're familiar with Powershell you can modify the script to operate however you think it should. This is extremely unfinished and wasn't really meant for a public release... some of my notes are probably no longer valid, and some features might have been broken the last time I was playing around with stuff. I won't offer support for this and I am not responsible for any unfortunate circumstances that may arise from the use of this script. It's not something I work on anymore because my wife prefers Jellyfin + ErsatzTV, and that's generally much easier for me to maintain.
 
Code:
# Commercials will not display in Kodi if they include the word "Trailer"

# -----TV Channel Management-----
    # Make sure file encoding is UTF-8-BOM or you will have a bad time
    # Please define some paths here
        # I have left my complete paths for easy reference
        # $schedule should be the path to the folder where you want your channel playlists to build
            # This path will also include lists of all associated commercials and bumpers for each channel
            # This will also be the directory where all database and .csv files will be created
        # $sqlite3 should point to the sqlite3 executable
        # $kodi should point to the Kodi Userdata folder

$regex = '[^a-zA-Z0-9]'
$schedule = "PATHTOSTOREPLAYLISTS(NOTKODIFOLDER)"
$sqlite3 = "PATHTO\sqlite3.exe"
$kodi = "PATHTO\userdata"
$logopath = "PATHTOCLEARLOGOS"

    # -----Update Cloned Database-----
        # Delete previous database clone
        # Create new database clone
        # Create .csv files for media types Episodes, Movies, and Shows from cloned database
            # Cloning of Kodi database prevents any unintended consequences of working with the database directly
            # Working from .csv files prevents the need for non-default Powershell modules
            # That said, SQLite3 is required
            # .csv conversion is imperfect. Some characters, such as the accented "E" in "Pokemon" do not translate well between formats
                # This is why there are multiple instances throughout the script to strip non-alphanumeric characters from the data being worked with
                # For certain titles, hardcoded instructions will be required
                # Special character exceptions are the primary reason the script builds .m3u files rather than .xml smart playlists
                    # We can work with standard Windows paths

Remove-Item "$schedule\MyVideos121.db" -Force
Copy-Item "$kodi\Database\MyVideos121.db" -Destination "$schedule\MyVideos121.db" -Force

& "$sqlite3" -safe -header -csv "$schedule\MyVideos121.db" "select * from episode_view;" > "$schedule\episodes.csv"
& "$sqlite3" -safe -header -csv "$schedule\MyVideos121.db" "select * from movie_view;" > "$schedule\movies.csv"
& "$sqlite3" -safe -header -csv "$schedule\MyVideos121.db" "select * from tvshow_view;" > "$schedule\shows.csv"
& "$sqlite3" -safe -header -csv "$schedule\MyVideos121.db" "select * from movielinktvshow;" > "$schedule\linkedmovies.csv"

    # -----Clean Misbehaving Channels-----
        # Only run if PC has been powered on for at least one hour (ensuring that all playlists have had the opportunity to update since last power down)
        # Find all playlists which have not been modified in the past hour and remove them

<# IF ( (New-TimeSpan -Start (Get-CimInstance Win32_OperatingSystem).LastBootUpTime -End (Get-Date)).Hours -gt 0 ) { @(Get-ChildItem "$schedule\Channels" -Recurse -Directory).ForEach({
(Get-ChildItem -literalpath $_.FullName -File | Where-Object { $_.Extension -notlike "*md5" -and $_.Name -ne "Binge Episodes.m3u" } ) | ForEach-Object { IF ( (New-TimeSpan -Start $_.LastWriteTime -End (Get-Date)).Hours -gt 0 ) { Remove-Item -literalpath $_.FullName -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue }
ELSE { } }
}) }
ELSE { } #>

        # Remove any channel and its components which contains missing video files
            # Prevent crashing in Kodi when trying to load a playlist with missing content

$channelstokill = @()

Get-ChildItem "$schedule\Channels" -File -Recurse -Filter "*m3u" | ForEach-Object { $channelpath = (($_.FullName) -replace "\\$_","")
$channel = $channelpath.split("\") | Select -Last 1
Get-Content -literalpath $_.FullName | Where-Object { "$_" -notmatch "EXTINF" -and "$_" -ne "" } | ForEach-Object { IF ( Test-Path -literalpath "$_" ) { }
ELSE { $channelstokill += "$channelpath"
Remove-Item "$schedule\database\bumpers\$channel.m3u" -Confirm:$false -Force -ErrorAction SilentlyContinue
Remove-Item "$schedule\database\commercials\$channel.m3u" -Confirm:$false -Force -ErrorAction SilentlyContinue } } }

$channelstokill | Sort -Unique | ForEach-Object { Remove-Item -literalpath "$_" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue }

    # -----Define Binge and Random Shows-----
        # -----Define Studios Which Have Corresponding Channels-----
            # The | character is not strictly required, but makes it easier for humans to read the data
            # Studios with corresponding channels (i.e.: "20th Century Fox" populates the channel "Fox") will not populate the "Other" channel
                # This allows the "Other" channel to be a "things with nowhere else to go" channel
            # Shows listed under $binge will not populate the regular schedule
                # Shows which have been watched ( playcount greater than or equal to 1 ) will always populate the Reruns playlist
                # If you do not care about bingeing content, please change the value of $binge to "N/A"
                    # An alternative benefit to using the $binge method of channel population is the script's ability to parse multi-episode files
                        # This makes it easy to binge-watch content such as children's cartoons without manually moving between episodes or splitting files
    
$binge = "Primal|Disenchantment|Harley Quinn|Star Trek: Lower Decks|Big Mouth|Riverdale|Star Wars: The Book of Boba Fett|Naomi|Peacemaker|Raised By Wolves (2020)|Made for Love|The Flight Attendant|Moon Knight|Star Wars: Obi-Wan Kenobi|The Boys|Fate: The Winx Saga"
import-CSV "$schedule\episodes.csv" | Where-Object { $_.strPath -like "*binge*" -and $_.Playcount -lt 1 } | Group-Object -Property strTitle | ForEach-Object { $_.Group | Select -First 1 } | ForEach-Object { $binge += ($_.strTitle -replace '[^a-zA-Z0-9]','') }
$cont = ""
$current = @("Chilling Adventures of Sabrina","Ben 10: Alien Force","Ben 10: Ultimate Alien","Hannibal","Powerpuff Girls Z")
$current = $current | ForEach-Object { "$_" -replace '[^a-zA-Z0-9]' }
$towatch = "$cont" + "The IT Crowd|Dinosaurs|Clarissa Explains It All|The Secret World of Alex Mack|Animorphs|The Conners|Kong: King of the Apes|Joey|Solar Opposites|Ned's Declassified School Survival Guide|Bojack Horseman|Scrubs: Interns|The Croods: Family Tree|Craig of the Creek|Tig n' Seek|RWBY Chibi|The Loud House|Q*Bert|Devil Hunter Yohko|Pepper Ann|Kimi ni Todoke: From Me to You|Vampire Knight|The Legend of Zelda|She-Ra and the Princesses of Power|Sailor Moon|Big Hero 6: The Series|Pokemon|Pokmon|Redwall|IGPX: Immortal Grand Prix"
$currentyear = 2023
$channelsprocessed = @()
$christmas = "Christmas|X-Mas|Santa Claus|Reindeer|Yule|Hannukah|Kwanza"

IF ( !(Test-Path "$schedule\database\commercials")) { New-Item "$schedule\database\commercials" -Force -ItemType Directory}
ELSE { }
IF ( !(Test-Path "$schedule\database\bumpers")) { New-Item "$schedule\database\bumpers" -Force -ItemType Directory}
ELSE { }
IF ( !(Test-Path "$schedule\database\series")) { New-Item "$schedule\database\series" -Force -ItemType Directory}
ELSE { }
IF ( !(Test-Path "$schedule\database\series\special")) { New-Item "$schedule\database\series\special" -Force -ItemType Directory}
ELSE { }
IF ( !(Test-Path "$schedule\database\reruns")) { New-Item "$schedule\database\reruns" -Force -ItemType Directory}
ELSE { }

    # -----Build Channels-----
    
$channels = @("Ion","Syfy","Excelsior!","Chiller","Magik","Cartoon Planet","Funimation Channel","Panda","Adult Swim","Cartoon Network","Cartoon Network Too","Netflix Kids","FX","Toonami","Hulu","ABC","Crunchyroll","The WB","HBO","CBS","Comedy Central","The N","SLAM!","Nickelodeon","NBC","Disney XD","Disney Channel","Disney Junior","Boomerang","Jetix","Forever Kids","Anime Network","Kodi TV","Spooky","Kids","LMAO","Laff")

        # -----Remove Obsolete Channel Resources-----

Get-ChildItem "$schedule\channels" -Directory | Where-Object { $channels -notcontains $_.Name } | Remove-Item -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem "$schedule\database\reruns" -Directory | Where-Object { $channels -notcontains $_.Name } | Remove-Item -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem ("$schedule\database\bumpers","$schedule\database\commercials","$schedule\database\series","$schedule\database\series\special") -File | Where-Object { $channels -notcontains (($_.Name) -replace ($_.extension,"")) } | Remove-Item -Confirm:$false -Force -ErrorAction SilentlyContinue
Get-ChildItem "$kodi\library\video\TV Shows\KodiTV" -File -Exclude "index.xml" | Where-Object { $channels -notcontains (($_.Name) -replace ($_.extension,"")) } | Remove-Item -Confirm:$false -Force -ErrorAction SilentlyContinue
Get-ChildItem "$kodi\playlists\video" -File -Filter "Channel*" | Where-Object { $channels -notcontains (((($_.Name) -replace ($_.extension,"")) -replace "Channel - ","") -replace " Movies","") } | Remove-Item -Confirm:$false -Force -ErrorAction SilentlyContinue

$channels.ForEach({

$channel = "$_"
$thisyear = @()
$newarrivals = @()
$autocurrent = @()
$episodes = @()
$movies = @()
$epmovs = @()
$series = @()

IF ( !(Test-Path "$schedule\database\reruns\$channel")) { New-Item "$schedule\database\reruns\$channel" -Force -ItemType Directory }
ELSE { }

$chanpath = $channel
$channelsprocessed += "$channel"

IF ( "Toonzai|Kids|Panda" -match $channel -and ((Get-Date (import-CSV "$schedule\episodes.csv" | Sort -desc -Property lastplayed | Select -First 1).lastplayed) -ge ((Get-ChildItem "$schedule\Channels\$chanpath" -File | Select -First 1).LastWriteTime))) { Remove-Item "$schedule\Channels\$chanpath" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue }
ELSE { }

IF ( !(Test-Path "$schedule\Channels\$chanpath") ) { $proceed = "True" }
ELSEIF ("Toonzai|Kids|Panda" -notmatch $channel -and (Get-Content "$schedule\Channels\$chanpath\Reruns.m3u" -ErrorAction SilentlyContinue).count -le 100) { $proceed = "True" }
ELSEIF ("Toonzai|Kids|Panda" -notmatch $channel -and (Get-Content "$schedule\Channels\$chanpath\New Episodes.m3u" -ErrorAction SilentlyContinue).count -le 100) { $proceed = "True" }
ELSE { $proceed = "False" }

IF ( $proceed -eq "False" ) { }
ELSE {

Write-Host "$_"

# Kids Animation Channels

IF ( $channel -eq "Cartoon Network" ) { $chanfil = '$_.studio -like "*Cartoon Network*" -and ($_.strFileName -like "chd1*" -or $_.strFileName -like "bby*")'
$movfil = '$_.C18 -match "Cartoon Network" -and $_.C14 -match "Kids|Children"' }
ELSEIF ( $channel -eq "Boomerang" ) { $chanfil = '$_.studio -match "Boomerang|DC Comics" -and $_.strFileName -match "bby|chd" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c18 -match "Warner" -and $_.c14 -match "Kids|Children" -and $_.c18 -match "Animation"' }
ELSEIF ( $channel -eq "Nickelodeon" ) { $chanfil = '$_.studio -match "Nickelodeon" -and $_.strFilename -match "chd1|bby" -and $_.strPath -notmatch "Disney|Jetix|Fox Kids|Netflix"'
$movfil = '$_.c18 -match "Nickelodeon"' }
ELSEIF ( $channel -eq "Disney XD" ) { $chanfil = '$_.studio -match "Disney" -and $_.strFilename -match "chd1" -and $_.strPath -notmatch "Nickelodeon"'
$movfil = '$_.c18 -match "Disney|Pixar" -and $_.c14 -match "Animation"' }
ELSEIF ( $channel -eq "Discovery Kids" ) { $chanfil = '$_.studio -match "Discovery" -and $_.strFileName -match "chd|bby"'
$movfil = '$_.c18 -match "Discovery" -and $_.c14 -match "Kids|Children"' }
ELSEIF ( $channel -eq "Netflix Kids" ) { $chanfil = '$_.studio -match "Netflix" -and $_.strFilename -match "chd|bby" -and $_.strPath -notmatch "The WB|Cartoon Network|Nickelodeon|Fox Kids|Jetix"'
$movfil = '$_.c18 -match "Netflix" -and $_.c14 -match "Kids|Children"' }
ELSEIF ( $channel -eq "Bohbot Kids Network" ) { $chanfil = '$_.studio -match "World of DIC"'
$movfil = '$_.c18 -match "World of DIC"' }
ELSEIF ( $channel -eq "Forever Kids" ) { $chanfil = '$_.strFileName -match "chd|bby" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c14 -match "Kids|Children" -and $showsonchannels -notcontains $_.c22' }
ELSEIF ( $channel -eq "Cartoon Planet" ) { $chanfil = '$_.strFileName -match "chd|bby"'
$movfil = '$_.c14 -match "Animation" -and $_.c14 -match "Kids|Children"' }

# Kids Action Channels

ELSEIF ( $channel -eq "Cartoon Network Too" ) { $chanfil = '(($_.studio -match "Cartoon Network" -and $_.strFileName -match "chd3") -or $_.studio -match "Kids WB") -and $_.strPath -notmatch "Disney XD|Netflix" -and $_.genre -notmatch "Anime"'
$movfil = '(($_.c18 -match "DC Comics|Warner Bros." -and $_.c14 -match "Kids|Family|Children") -or $_.c18 -match "Cartoon Network") -and $_.c14 -match "Superhero|Science Fiction" -and $_.c14 -notmatch "Anime"' }
ELSEIF ( $channel -eq "Kids WB" ) { $chanfil = '$_.studio -match "Kids WB" -and $_.strPath -notmatch "Cartoon Network|Disney XD|Netflix"'
$movfil = '$_.c18 -match "Warner" -and $_.c14 -match "Kids|Children"' }
ELSEIF ( $channel -eq "SLAM!" ) { $chanfil = '($_.studio -match "Nickelodeon" -and $_.strFilename -match "chd3" -and $_.strPath -notmatch "Jetix|Netflix|Fox Kids") -or $_.strTitle -eq "Teenage Mutant Ninja Turtles"'
$movfil = '$_.c18 -match "Nickelodeon" -and $_.c14 -match "Anime|Action|Adventure|Superhero|Science Fiction|Fantasy|Horror"' }
ELSEIF ( $channel -eq "Jetix" ) { $chanfil = '(($_.studio -match "Disney|Marvel Comics" -and $_.strFilename -match "chd3*" -and $showsonchannels -notcontains $_.c18) -or $_.studio -match "Fox Kids" -or "Sonic the Hedgehog|Street Sharks" -match $_.strTitle ) -and $_.strPath -notmatch "Nickelodeon|TheWB|Cartoon Network"'
$movfil = '$_.c18 -match "Studio Ghibli" -or ($_.c18 -match "Marvel Comics|Fox" -and $_.c14 -match "Kids|Children|Family") -or ($_.c18 -match "Disney|Pixar" -and $_.c14 -match "Anime|Action|Adventure|Superhero|Science Fiction")' }
ELSEIF ( $channel -eq "Fox Kids" ) { $chanfil = '$_.studio -match "Fox Kids" -and $_.strPath -notmatch "Jetix|Nickelodeon|Netflix"'
$movfil = '$_.c18 -match "Fox|Blue Sky Studios" -and $_.c14 -match "Kids|Children|Family"' }

# Pre-School Channels

ELSEIF ( $channel -eq "Disney Junior" ) { $chanfil = '$_.studio -match "Disney|Marvel Comics" -and $_.strFilename -match "bby"'
$movfil = '$_.c18 -match "Disney|Marvel Comics" -and $_.strFilename -match "bby"' }

# Other Kids Channels

ELSEIF ( $channel -eq "The N" ) { $chanfil = '$_.studio -match "Nickelodeon|Paramount+" -and $_.strFilename -match "chd2|cmda"'
$movfil = '$_.c18 -match "Nickelodeon" -and $_.c14 -match "Comedy" -and $_.c14 -notmatch "Animation|Anime"' }
ELSEIF ( $channel -eq "Disney Channel" ) { $chanfil = '$_.studio -match "Disney|ABC" -and (($_.Genre -match "Family" -and $_.strFileName -match "cmda") -or $_.strFileName -match "chd2")'
$movfil = '$_.c18 -match "Disney" -and $_.c14 -notmatch "Animation|Anime" -and $_.c14 -match "Comedy"' }

# Anime Channels

ELSEIF ( $channel -eq "Toonami" ) { $chanfil = '$_.studio -match "Cartoon Network|Kids WB" -and $_.Genre -match "Anime"'
$movfil = '$_.c18 -match "Cartoon Network|Kids WB|Warner" -and $_.c14 -match "Anime"' }
ELSEIF ( $channel -eq "Crunchyroll" ) { $chanfil = '$_.studio -match "Crunchyroll|Rooster Teeth"'
$movfil = '$_.c18 -match "Crunchyroll|Rooster Teeth"' }
ELSEIF ( $channel -eq "Funimation Channel" ) { $chanfil = '$_.studio -match "Funimation Channel|Independent Film Channel"'
$movfil = '$_.c18 -match "Funimation Channel|Independent Film Channel"' }
ELSEIF ( $channel -eq "Anime Network" ) { $chanfil = '$_.Genre -match "Anime" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c14 -match "Anime" -and $showsonchannels -notcontains $_.c22' }

# Adult Animation Channels

ELSEIF ( $channel -eq "Adult Swim" ) { $chanfil = '$_.studio -match "Cartoon Network" -and $_.strFileName -match "cmdb|mtra" -and $_.Genre -notmatch "Anime"'
$movfil = '$_.c18 -match "Cartoon Network|Warner Bros.|DC Comics" -and $_.c14 -match "Animation" -and $_.c14 -notmatch "Anime|Kids|Children"' }
ELSEIF ( $channel -eq "Comedy Central" ) { $chanfil = '$_.studio -match "Comedy Central"'
$movfil = '$_.c18 -match "Comedy Central"' }
ELSEIF ( $channel -eq "Hulu" ) { $chanfil = '$_.studio -match "Hulu|USA Network|Disney|Fox|Marvel Comics" -and $showsonchannels -notcontains $_.c18 -and $_.strFileName -match "cmdb|mtra" -and $_.strTitle -notmatch "Naruto"'
$movfil = '$_.c18 -match "Hulu|USA Network|Marvel Comics|Disney|Fox" -and $_.c14 -notmatch "Kids|Children" -and $_.c14 -match "Animation|Anime"' }
ELSEIF ( $channel -eq "LMAO" ) { $chanfil = '$_.strFileName -match "cmdb" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c14 -match "Comedy" -and $_.c14 -notmatch "Kids|Children|Anime" -and $_.c14 -match "Animation" -and $showsonchannels -notcontains $_.c22' }

# Drama Channels

ELSEIF ( $channel -eq "The WB" ) { $chanfil = '$_.studio -match "The WB|The CW" -or ($_.studio -match "DC Comics" -and $showsonchannels -notcontains $_.c18) -and $_.strFileName -match "cmda|mtrb"'
$movfil = '$_.c18 -match "Warner" -and $_.c14 -notmatch "Kids|Children|Anime|Animation"' }
ELSEIF ( $channel -eq "HBO" ) { $chanfil = '$_.studio -match "HBO|HBO Max|TBS|TNT" -and $_.strFileName -match "cmda|mtrb"'
$movfil = '$_.c18 -match "HBO|HBO Max" -and $_.c14 -notmatch "Kids|Children|Anime|Animation"' }
ELSEIF ( $channel -eq "USA" ) { $chanfil = '$_.studio -match "NBC|USA Network|Syfy|Peacock|Universal" -and $_.strFilename -match "mtrb"'
$movfil = '$_.c18 -match "Universal" -and $_.c14 -notmatch "Kids|Children|Anime|Animation|Comedy"' }
ELSEIF ( $channel -eq "CBS" ) { $chanfil = '$_.studio -match "CBS|Paramount|Showtime|Spike|UPN" -and $_.strFileName -match "mtrb|cmda"'
$movfil = '$_.c18 -match "CBS|Paramount" -and $_.c14 -notmatch "Kids|Children|Anime|Animation"' }
ELSEIF ( $channel -eq "ABC" ) { $chanfil = '$_.studio -match "ABC" -and $_.strFileName -match "mtrb|cmda"'
$movfil = '$_.c18 -match "ABC|Disney" -and $_.c14 -notmatch "Kids|Children|Anime|Animation"' }
ELSEIF ( $channel -eq "FX" ) { $chanfil = '$_.Studio -match "ABC Family|Fox|FX|Freeform|Disney|Hulu|Marvel Comics" -and $_.strFileName -match "mtrb|cmda" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c18 -match "Fox|Hulu|Marvel Comics" -and $_.c14 -notmatch "Kids|Children|Animation|Anime"' }
ELSEIF ( $channel -eq "Kodi TV" ) { $chanfil = '$_.strFileName -match "mtrb" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c14 -notmatch "Kids|Children|Animation|Anime|Comedy" -and $showsonchannels -notcontains $_.c22' }

# Comedy Channels

ELSEIF ( $channel -eq "NBC" ) { $chanfil = '$_.studio -match "NBC|Universal|USA|Syfy|Peacock" -and $_.strFilename -match "cmda|mtrb"'
$movfil = '$_.c18 -match "Universal" -and $_.c14 -notmatch "Kids|Children|Anime|Animation"' }
ELSEIF ( $channel -eq "ABC Family" ) { $chanfil = '$_.studio -match "ABC|ABC Family|Freeform|Hulu" -and $_.strFilename -match "cmda"'
$movfil = '$_.c18 -match "ABC" -and $_.c14 -match "Comedy" -and $_.c14 -notmatch "Kids|Children|Anime|Animation"' }
ELSEIF ( $channel -eq "Laff" ) { $chanfil = '$_.strFileName -match "cmda" -and $showsonchannels -notcontains $_.c18'
$movfil = '$_.c14 -match "Comedy" -and $_.c14 -notmatch "Kids|Children|Animation|Anime" -and $showsonchannels -notcontains $_.c22' }

# Specialty Channels

ELSEIF ( $channel -eq "Spooky" ) { $chanfil = '$_.Genre -match "Horror" -and $_.Genre -match "Kids|Children|Family"'
$movfil = '$_.C14 -match "Horror" -and $_.C14 -match "Kids|Children|Family"' }
ELSEIF ( $channel -eq "Syfy" ) { $chanfil = '$_.Genre -match "Science Fiction" -and $_.strFileName -match "cmda|mtrb" -and $_.Genre -notmatch "Superhero"'
$movfil = '$_.C14 -match "Science Fiction" -and $_.C14 -notmatch "Kids|Children|Animation|Anime|Superhero"' }
ELSEIF ( $channel -eq "Excelsior!" ) { $chanfil = '$_.Genre -match "Superhero" -and $_.strFileName -match "cmda|mtrb"'
$movfil = '$_.C14 -match "Superhero" -and $_.C14 -notmatch "Kids|Children|Animation|Anime"' }
ELSEIF ( $channel -eq "Chiller" ) { $chanfil = '$_.Genre -match "Horror" -and $_.strFileName -match "cmda|mtrb"'
$movfil = '$_.C14 -match "Horror" -and $_.C14 -notmatch "Kids|Children|Animation|Anime"' }
ELSEIF ( $channel -eq "Magik" ) { $chanfil = '$_.Genre -match "Fantasy" -and $_.strFileName -match "cmda|mtrb"'
$movfil = '$_.C14 -match "Fantasy" -and $_.C14 -notmatch "Kids|Children|Animation|Anime"' }
ELSEIF ( $channel -eq "Ion" ) { $chanfil = '$_.Genre -notmatch "Science Fiction|Superhero|Comedy|Horror|Fantasy" -and $_.strFileName -match "cmda|mtrb"'
$movfil = '$_.C14 -notmatch "Kids|Children|Family|Animation|Anime|Science Fiction|Superhero|Comedy|Horror|Fantasy"' }

# Current Season Channels

ELSEIF ( $channel -eq "Kids" ) { $chanfil = '$_.C18 -like "*o*" -and $_.strFileName -notlike "mtrb*"'
$movfil = '$_.strPath -like "*o*" -and $_.strFileName -notlike "mtrb*"' }
ELSEIF ( $channel -eq "Panda" ) { $chanfil = '$_.C18 -like "*o*"'
$movfil = '$_.strPath -like "*o*"' }
ELSEIF ( $channel -eq "Toonzai" ) { $chanfil = '$_.C18 -notlike "*\Together\*" -and $_.strFileName -notlike "mtrb*" -and $_.strTitle -ne "Dragon Ball GT"'
$movfil = '$_.strPath -notlike "*\Together\*" -and $_.strFileName -notlike "mtrb*"' }
ELSE { }

######

$showsonchannels = @()
Get-ChildItem "$schedule\database\series" -File -Filter "*m3u" | Where-Object { $_.Name -notmatch "$channel.m3u" } | ForEach-Object { $showsonchannels += Get-Content -literalpath $_.FullName }
$showsonchannels = $showsonchannels | Sort -Unique
$episodes = import-CSV "$schedule\episodes.csv" | Where-Object { ( invoke-expression $chanfil ) }
$movies = import-CSV "$schedule\movies.csv" | Where-Object { ( invoke-expression $movfil ) }

IF ( @($episodes | ? { $_.strPath -match "Pokemon" }) ) { $episodes += @(import-CSV "$schedule\episodes.csv" | Where-Object { $_.strPath -match "Pokemon" }) }
ELSE { }

$movies | ForEach-Object { $_ | Add-Member -MemberType NoteProperty -Name "strTitle" -Value $_.strSet
$_ | Add-Member -MemberType NoteProperty -Name "idShow" -Value "NOSERIES" }

$epmovs = $episodes | Select -ExpandProperty IdShow | Sort -Unique | ForEach-Object { $id = "$_"
import-CSV "$schedule\linkedmovies.csv" | Where-Object { $_.IdShow -eq $id } | Select -ExpandProperty IdMovie | ForEach-Object { $movid = "$_"
import-CSV "$schedule\movies.csv" | Where-Object { $_.idMovie -eq $movid } } }

$epmovs | ForEach-Object { $movid = $_.idMovie
import-CSV "$schedule\linkedmovies.csv" | Where-Object { $_.idmovie -eq $movid } | Select -ExpandProperty IdShow | ForEach-Object { $showid = "$_"
$showtit = import-CSV "$schedule\episodes.csv" | Where-Object { $_.idshow -eq $showid } | Select -First 1 | Select -ExpandProperty strTitle }
$_ | Add-Member -MemberType NoteProperty -Name "strTitle" -Value $showtit
$_ | Add-Member -MemberType NoteProperty -Name "idShow" -Value $showid }

$movies += $epmovs

IF ( "Panda" -match $channel ) { }
ELSE { $movies = $movies | Group-Object -Property c22 | ForEach-Object { $_.Group | Sort -Property idShow | Select -First 1 } }

$moviefiles = @()
$movies | ForEach-Object { $moviefiles += '<value>'+$_.strFileName+'</value>' }

'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="movies">
    <name>'+"Channel - $channel Movies"+'</name>
    <match>all</match>
    <rule field="filename" operator="is">'+$moviefiles+'</rule>
    <order direction="ascending">sorttitle</order>
    <group>none</group>
</smartplaylist>' | Out-File "$kodi\playlists\video\Channel - $channel Movies.xsp" -Encoding UTF8

$episodes | ForEach-Object { $series += $_.idShow }

$episodeids = @()
$episodeids += $episodes | Where-Object { $_.strPath -notlike "*\Movies\*" } | Select -ExpandProperty c18
$episodeids += $episodes | Where-Object { $_.strPath -like "*\Movies\*" } | Select -ExpandProperty c22

$series = $series | Sort -Unique
IF ( "Kids|Toonzai|Panda|Cartoon Planet|Forever Kids|Anime Network|Kodi TV|Spooky|Laff|Syfy|Excelsior!|Chiller|Magik|Ion" -notmatch $channel ) { Remove-Item "$schedule\database\series\$channel.m3u" -Confirm:$false -Force -ErrorAction SilentlyContinue
Add-Content -Force -Path "$schedule\database\series\$channel.m3u" -Value ($episodeids | Sort -Unique) }
ELSE { Remove-Item "$schedule\database\series\special\$channel.m3u" -Confirm:$false -Force -ErrorAction SilentlyContinue
Add-Content -Force -Path "$schedule\database\series\special\$channel.m3u" -Value ($episodeids | Sort -Unique) }

    
$series = @(import-CSV "$schedule\shows.csv" | Where-Object { $series -contains $_.idShow } | ForEach-Object {'<value>'+$_.strPath+'</value>'} )

'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="tvshows">
    <name>'+"Channel - $channel"+'</name>
    <match>all</match>
    <rule field="path" operator="is">'+$series+'</rule>
    <order direction="ascending">sorttitle</order>
</smartplaylist>' | Out-File "$kodi\playlists\video\Channel - $channel.xsp" -Encoding UTF8

$series = @()

$episodes += $movies

$movies = @()
$epmovs = @()

IF ( "Kids|Panda" -match $channel ) { }
ELSEIF ( "Toonzai" -match $channel ) { $episodes = $episodes | Where-Object { $_.strPath -notlike "*\Together\*" -or $_.Playcount -ge 1 } }
ELSE { $episodes = $episodes | Where-Object { $_.strPath -notlike "*\Together\*" -or $_.Playcount -ge 1 } }

# Series Groups

$ben10 = ($episodes | Where-Object { $_.strTitle -eq "Ben 10" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Ben 10" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $ben10 }
$naruto = ($episodes | Where-Object { $_.strTitle -eq "Naruto" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Naruto" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $naruto }
$walkingdead = ($episodes | Where-Object { $_.strTitle -eq "The Walking Dead" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Walking Dead" -and $_.strPath -match "Torn Apart" } | ForEach-Object { $_.idShow = $walkingdead + ".tornapart" }
$digimon = ($episodes | Where-Object { $_.strTitle -match "Digimon" } | Sort -Property premiered | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Digimon" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $digimon }
$scrubs = ($episodes | Where-Object { $_.strTitle -eq "Scrubs" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Scrubs" -and $_.playcount -ge 1 -and $_.strPath -match "Med-School" } | ForEach-Object { $_.idShow = $scrubs + ".medschool" }
    $episodes | Where-Object { $_.strTitle -match "Scrubs" -and $_.playcount -ge 1 -and $_.strPath -match "Interns" } | ForEach-Object { $_.idShow = $scrubs + ".interns" }
$igpx = ($episodes | Where-Object { $_.strTitle -match "IGPX" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "IGPX" -and $_.strFileName -match "tnmi" } | ForEach-Object { $_.idShow = $igpx + ".toonami" }
$sailormoon = ($episodes | Where-Object { $_.strTitle -match "Sailor Moon" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Sailor Moon" -and $_.strFileName -match "viz" -and $_.strPath -notmatch "Sailor Stars" } | ForEach-Object { $_.idShow = $igpx + ".viz" }
$mcu = ($episodes | Where-Object { $_.strTitle -match "WandaVision" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Loki" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $mcu }
    $episodes | Where-Object { $_.strTitle -match "Moon Knight" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $mcu }
    $episodes | Where-Object { $_.strTitle -match "She-Hulk" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $mcu }
    $episodes | Where-Object { $_.strTitle -match "Winter Soldier" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $mcu }
    $episodes | Where-Object { $_.strTitle -match "What If" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $mcu }
    $episodes | Where-Object { $_.c18 -match "Marvel Studios" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $mcu }
$starwars = ($episodes | Where-Object { $_.strTitle -match "Star Wars" } | Sort -Property premiered | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Star Wars" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $starwars }
    $episodes | Where-Object { $_.c00 -match "Star Wars" -and $_.playcount -lt 1 -and $_.strPath -like "*\Movies\*" } | ForEach-Object { $_.idShow = $starwars }
$rescueriders = ($episodes | Where-Object { $_.strTitle -match "Rescue Riders" } | Sort -Property premiered | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Rescue Riders" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $rescueriders }
$arrowverse = ($episodes | Where-Object { $_.strTitle -eq "Arrow" } | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -eq "The Flash (2014)" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $arrowverse }
    $episodes | Where-Object { $_.strTitle -eq "Supergirl" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $arrowverse }
    $episodes | Where-Object { $_.strTitle -match "Legends of Tomorrow" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $arrowverse }
    $episodes | Where-Object { $_.strTitle -match "Black Lightning" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $arrowverse }
$scoobydoo = ($episodes | Where-Object { $_.strTitle -match "Scooby-Doo" } | Sort -Property premiered | Select -First 1 | Select -ExpandProperty idShow)
    $episodes | Where-Object { $_.strTitle -match "Scoob" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = $scoobydoo }
    
$episodes | Where-Object { $_.strPath -like "*\Bonus\*" -and $_.playcount -lt 1 } | ForEach-Object { $_.idShow = "bonus." + $idShow }

# Title Changes

$episodes | Where-Object { $_.strTitle -match "Doug" -and $_.strPath -like "*Disney*" } | ForEach-Object { $_.strTitle = "Disney's Doug" }
$episodes | Where-Object { $_.strTitle -match "Power Rangers" -and $_.strPath -like "*Megaforce*" -and $_.strPath -notlike "*Super Megaforce*" } | ForEach-Object { $_.strTitle = "Power Rangers: Megaforce" }
$episodes | Where-Object { $_.strTitle -match "Power Rangers" -and $_.strPath -like "*Super Megaforce*" } | ForEach-Object { $_.strTitle = "Power Rangers: Super Megaforce" }
$episodes | Where-Object { $_.strTitle -match "Power Rangers" -and $_.strPath -like "*Ninja Storm*" } | ForEach-Object { $_.strTitle = "Power Rangers: Ninja Storm" }
$episodes | Where-Object { $_.strTitle -match "Walking Dead" -and $_.strPath -match "Torn Apart" } | ForEach-Object { $_.strTitle = "The Walking Dead: Torn Apart" }
$episodes | Where-Object { $_.strTitle -match "Scrubs" -and $_.strPath -match "Med-School" } | ForEach-Object { $_.strTitle = "Scrubs: Med-School" }
$episodes | Where-Object { $_.strTitle -match "Scrubs" -and $_.strPath -match "Interns" } | ForEach-Object { $_.strTitle = "Scrubs: Interns" }
$episodes | Where-Object { $_.strTitle -match "Scooby-Doo!" -and $_.strPath -like "*New Scooby-Doo Movies*" } | ForEach-Object { $_.strTitle = "The New Scooby-Doo Movies" }
$episodes | Where-Object { $_.strTitle -match "Scooby-Doo!" -and $_.strPath -like "*The 13 Ghosts of Scooby-Doo*" } | ForEach-Object { $_.strTitle = "The 13 Ghosts of Scooby-Doo" }
$episodes | Where-Object { $_.strTitle -match "Scooby-Doo!" -and $_.strPath -like "*Scooby-Doo and Scrappy-Doo*" } | ForEach-Object { $_.strTitle = "Scooby-Doo and Scrappy-Doo" }
$episodes | Where-Object { $_.strTitle -match "Jonny Quest" -and $_.strPath -like "*New Adventures of Jonny Quest*" } | ForEach-Object { $_.strTitle = "The New Adventures of Jonny Quest" }

$episodes | Where-Object { $_.strPath -like "*\Movies and Specials\*" } | ForEach-Object { $_.strTitle = $_.C00 }

$episodes | Where-Object { $_.strTitle -match "Pok├⌐mon" } | ForEach-Object { $_.strTitle = ($_.strTitle -replace "Pok├⌐mon","Pokémon") }
$episodes | Where-Object { $_.strTitle -match "Pokemon" } | ForEach-Object { $_.strTitle = ($_.strTitle -replace "Pokemon","Pokémon") }
$episodes | Where-Object { $_.strTitle -match "Ranma" } | ForEach-Object { $_.strTitle = ($_.strTitle -replace "Ranma ┬╜","Ranma ½") }

#####

IF ( "Toonzai|Kids|Panda" -match $channel ) { $episodes | Where-Object { ([int]($_.c05).substring(0,4) -ge $currentyear) } | Select -ExpandProperty idShow | Sort -Unique | ForEach-Object {$thisyear += ("$_" + "|")}
$episodes | Where-Object { ([int]($_.dateAdded).substring(0,4) -ge 2023) } | Select -ExpandProperty idShow | Sort -Unique | ForEach-Object {$newarrivals += ("$_" + "|")}
$episodes | Where-Object { $_.Playcount -eq 1 -and [DateTime]($_.lastPlayed) -ge (Get-Date).AddDays(-60) -and $_.strFilename -notlike "sf*" } | Group-Object strTitle | Sort -Desc -Property Count | ForEach-Object { $showid = $_.Group | Select -First 1 | Select -ExpandPropert idShow
$remaining = ($episodes | Where-Object { $_.playcount -lt 1 -and $_.strFileName -notlike "sf*" -and $_.idshow -eq $showid } ).count
IF ( $remaining -gt 0 -and ($_.Group).count -gt 1 ) { $autocurrent += ("$showid" + "|") }
ELSE { } } }
ELSE { }

IF ((Get-Content "$schedule\Channels\$chanpath\Reruns.m3u" -ErrorAction SilentlyContinue).count -ge 100) { $episodes = $episodes | Where-Object { $_.playcount -lt 1 } }
ELSE { }

IF ((Get-Content "$schedule\Channels\$chanpath\New Episodes.m3u" -ErrorAction SilentlyContinue).count -ge 100) { $episodes = $episodes | Where-Object { $_.playcount -ge 1 } }
ELSE { }

# The following section will select only the next episodes to watch from the lists of all episodes for the Channel

#Episode Ordering
    # This section will allow you to organize shows how you like
        # If you have multiple editions of an episode, you can use its filename or path to sort the extended edition to the back of the entire series, if you so choose
            # By default series sort as "00" | If you want to send an episode to the end of the list, simply tell it to sort as "Extended" or some name that will sort after "0"

$episodes = $episodes | Sort -Property ({IF ($_.strTitle -eq "Sailor Moon" -and $_.strPath -match "Sailor Stars") { "Sailor Stars" }
ELSEIF ($_.strPath -like "*\Versions\*" ) { "Alternate Versions" }
ELSE { "00" } }),({IF ( $_.strPath -like "*\Movies\*" ) { $_.Premiered }
ELSE { $_.c05 } }),strFileName | #Pipe

    # If you want to split a series into multiple selections (for example, Power Rangers into "Mighty Morphin Power Rangers" and "Power Rangers Zeo") you must do so here
        # This will ensure that at least one episode of Mighty Morphin and one episode of Zeo is selected
            # You may also use this section to combine shows (Ex: "Dragons: Rescue Riders" combined with "Dragons Rescue Riders: Heroes of the Sky") into one

Group-Object -Property ( { IF ( $_.strTitle -match "Spirit: Riding Free" -and $_.strPath -match "Pony Tales") { "Spirit: Riding Free - Pony Tales" }
ELSEIF ( $_.strTitle -match "Tales of Arcadia" -and $_.strPath -match "3Below") { "3Below: Tales of Arcadia" }
ELSEIF ( $_.strTitle -match "Tales of Ladybug" -and $_.strPath -match "Tales from Paris") { "Miraculous: Tales from Paris" }
ELSEIF ( $_.strTitle -match "Tales of Ladybug" -and $_.strPath -match "Zag Chibi") { "Miraculous Zag Chibi" }
ELSE { $_.idShow } } ) | #Pipe

#Binge Episodes
ForEach-Object { IF ( "Panda" -match $channel ) { $_.Group | Where-Object { $_.Playcount -lt 1 -and $_.strPath -like "*binge*" } }
ELSEIF ( "N/A" -eq $channel ) { $_.Group | Where-Object { $_.Playcount -lt 1 } }
ELSE { }

IF ((Get-Date).Month -eq 12 -and "Panda|Toonzai|Kids" -notmatch $channel ) { $_.Group | Where-Object { $_.strPath -match "$christmas" -or $_.strFilename -match "$christmas" -or $_.C00 -match "$christmas" -or $_.C01 -match "$christmas" } }
ELSE { }

#Unwatched Episodes
$_.Group | Where-Object { $_.playcount -lt 1 } | Select -First 1
#Reruns
$show = $_.Group | Where-Object { $_.playcount -ge 1 } | Select -First 1 | Select -ExpandPropert idShow
$playedepisodes = Get-Content "$schedule\database\reruns\$channel\$show.m3u"
IF ( ($_.Group | Where-Object { $_.playcount -ge 1 -and $playedepisodes -notcontains $_.strFilename }).count -lt 1 ) { Remove-Item "$schedule\database\reruns\$channel\$show.m3u" -Confirm:$false -Force -ErrorAction SilentlyContinue
$_.Group | Where-Object { $_.playcount -ge 1 } | Select -First 1 }
ELSE { $_.Group | Where-Object { $_.playcount -ge 1 -and $playedepisodes -notcontains $_.strFilename } | Select -First 1 } } | #Pipe
#Finishing Segment
Group-Object -Property strFileName | ForEach-Object { $_.Group | Select -First 1 }

# KodiTV

$episodes | Where-Object { $_.playcount -ge 1 } | ForEach-Object { $show = $_.idshow
Add-Content -Force -Path "$schedule\database\reruns\$channel\$show.m3u" -Value $_.strFileName }

$playlist = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="episodes">
    <name>' + "Next Up on $channel" + '</name>
    <match>all</match>
    <rule field="filename" operator="is">
'

$seriespath = @( $episodes | Where-Object { $_.strPath -notlike "*\Movies\*" } | Select -ExpandProperty strPath | Sort -Unique | ForEach-Object { ( "$_".split("\") | Select -First 3 ) -join "\" } | Sort -Unique)

$videos = @()
$videos += @( Get-Content "$schedule\database\commercials\$channel.m3u" )
$videos += @( Get-Content "$schedule\database\bumpers\$channel.m3u" )


$videos | ForEach-Object { IF ( Test-Path "$_" ) { }
ELSE { Remove-Item "$schedule\$chanpath.m3u" -Force } }

$spc = @()
$nue = @()
$rrn = @()
$runtime = 0
$schedtime = 0
$chan = @()

$seriespath.foreach({
Get-ChildItem -literalpath "$_" -File -Recurse | Where-Object { $_.FullName -like "*Extras*" -or $_.FullName -like "*Previews*" -and ".srt|.md5|.nfo" -notmatch [string]($_.Extension) } | ForEach-Object { IF ( $videos -contains $_.FullName ) { } 
ELSE { $spc += $_.FullName } }
})

$episodes | Where-Object { $_.strPath -like "*\Movies\*" } | Select -ExpandProperty strPath | ForEach-Object { Get-ChildItem "$_\Extras" -File -Recurse | Where-Object { ".srt|.md5|.nfo" -notmatch [string]($_.Extension) } | ForEach-Object { IF ( $videos -contains $_.FullName ) { }
ELSE { $spc += $_.FullName } } }

IF ( ($spc | Where-Object { "$_" -like "*Previews*" }).count -ge 1 -and !(Test-Path "$schedule\database\commercials\$channel.m3u") ) { New-Item "$schedule\database\commercials\$channel.m3u" -Force -ItemType File }
ELSE { }
IF ( ($spc | Where-Object { "$_" -like "*Bumpers*" }).count -ge 1 -and !(Test-Path "$schedule\database\bumpers\$channel.m3u") ) { New-Item "$schedule\database\bumpers\$channel.m3u" -Force -ItemType File }
ELSE { }

$spc | Where-Object { "$_" -like "*Previews*" } | ForEach-Object { Add-Content -Path "$schedule\database\commercials\$channel.m3u" -Value "$_" }
$spc | Where-Object { "$_" -like "*Bumpers*" } | ForEach-Object { Add-Content -Path "$schedule\database\bumpers\$channel.m3u" -Value "$_" }

IF ( "Panda" -match $channel ) { $chan += $episodes | Where-Object { $_.Playcount -ge 1 -or $_.strPath -notlike "*binge*" }
$chan += $episodes | Where-Object { $_.strPath -like "*Binge*" } | Sort-Object -Property ({IF ( $_.Playcount -ge 1 ) { "RE" }
ELSEIF (( $current -contains ($_.strTitle -replace '[^a-zA-Z0-9]') ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "01" }
ELSEIF (( $thisyear -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "02" }
ELSEIF (( $newarrivals -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "03" }
ELSEIF (( $current -contains ($_.strTitle -replace '[^a-zA-Z0-9]') ) -and $_.strPath -like "*Binge*") { "04" }
ELSEIF (( $thisyear -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*") { "05" }
ELSEIF (( $newarrivals -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*") { "06" }
ELSE { "10" } }),idShow | Select -First 1 | ForEach-Object { $showid = $_.idshow
$episodes | Where-Object { $_.idShow -eq $showid } } }
ELSE { $chan += @($episodes) }

IF ( "Toonzai|Kids|Panda" -match $channel ) { $chan = ( $chan | sort -property ({ IF ( $_.Playcount -ge 1 ) { "RE" }
ELSEIF ( $_.strFilename -like "sf*" -or $_.strFilename -like "nf*" ) { "BS" }
ELSEIF (( $current -contains ($_.strTitle -replace '[^a-zA-Z0-9]') ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "01" }
ELSEIF (( $autocurrent -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "03" }
ELSEIF (( $thisyear -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "05" }
ELSEIF (( $current -contains ($_.strTitle -replace '[^a-zA-Z0-9]') ) -and $_.strPath -like "*\Together\*") { "02" }
ELSEIF (( $autocurrent -contains ($_.idShow + "|") ) -and $_.strPath -like "*\Together\*") { "04" }
ELSEIF (( $thisyear -contains ($_.idShow + "|") ) -and $_.strPath -like "*\Together\*") { "06" }
ELSEIF (( $newarrivals -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*" -and $_.strPath -like "*\Together\*") { "20" }
ELSEIF (( $newarrivals -contains ($_.idShow + "|") ) -and $_.strPath -like "*\Together\*") { "21" }
ELSEIF (( $current -contains ($_.strTitle -replace '[^a-zA-Z0-9]') ) -and $_.strPath -like "*Binge*") { "10" }
ELSEIF (( $autocurrent -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*") { "12" }
ELSEIF (( $thisyear -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*") { "14" }
ELSEIF (( $newarrivals -contains ($_.idShow + "|") ) -and $_.strPath -like "*Binge*") { "22" }
ELSEIF (( $current -contains ($_.strTitle -replace '[^a-zA-Z0-9]') )) { "11" }
ELSEIF (( $autocurrent -contains ($_.idShow + "|") )) { "13" }
ELSEIF (( $thisyear -contains ($_.idShow + "|") )) { "15" }
ELSEIF (( $newarrivals -contains ($_.idShow + "|") )) { "23" }
ELSEIF (( ("$towatch" -replace '[^a-zA-Z0-9]') -match ($_.strTitle -replace '[^a-zA-Z0-9]') )) { "19" }
ELSE { "99" }}),idShow )

$chan = $chan | ForEach-Object { IF ($schedtime -ge 5400 -and "Panda" -notmatch $channel) { }
ELSEIF ("Panda" -match $channel -and $schedtime -ge 5400 -and ($_.strPath -notlike "*binge*" -or $_.Playcount -ge 1)) { }

ELSEIF ($_.strPath -like "*\Movies\*" -and [int]$_.C11 -le 600 ) { $schedtime += ([int]$_.C11)
$_ }
ELSEIF ($_.strPath -notlike "*\Movies\*" -and [int]$_.C09 -le 600 ) { $schedtime += ([int]$_.C09)
$_ }
ELSEIF ( $schedtime -ge 4800 -and "Panda" -notmatch $channel ) { }
ELSEIF ("Panda" -match $channel -and $schedtime -ge 4800 -and ($_.strPath -notlike "*binge*" -or $_.Playcount -ge 1)) { }

ELSEIF ($_.strPath -like "*\Movies\*" ) { $schedtime += ([int]$_.C11)
$_ }
ELSE { IF ($_.C09 -eq 0) { $showid = $_.idshow 
$schedtime += [int](import-CSV "$schedule\shows.csv" | Where-Object { $_.idshow -eq "$showid" } | Select -ExpandProperty duration) }
ELSE { $schedtime += ([int]$_.C09) }
$_ } }

$schedtime = 0

$chan = $chan | Sort -desc -Property ({IF ($_.strPath -like "*\Movies\*") { [int]$_.C11 }
ELSE { [int]$_.C09 } }) | ForEach-Object { IF ($schedtime -ge 5400 -and "Panda" -notmatch $channel) { }
ELSEIF ("Panda" -match $channel -and $schedtime -ge 5400 -and ($_.strPath -notlike "*binge*" -or $_.Playcount -ge 1)) { }
ELSEIF ($_.strPath -like "*\Movies\*" ) { $schedtime += ([int]$_.C11)
$_ }
ELSE { IF ($_.C09 -eq 0) { $showid = $_.idshow 
$schedtime += [int](import-CSV "$schedule\shows.csv" | Where-Object { $_.idshow -eq "$showid" } | Select -ExpandProperty duration) }
ELSE { $schedtime += ([int]$_.C09) }
$_ } } }
ELSE { }

$chan = ( $chan | sort -property ({ IF ( $_.strFileName -like "BBY*" ) { "A1" }
ELSEIF ( $_.strFileName -like "CHD1*" ) { "B1" }
ELSEIF ( $_.strFileName -like "CHD2*" ) { "B2" }
ELSEIF ( $_.strFileName -like "CHD3*" -and $_.Genre -like "*Anime*" ) { "B4" }
ELSEIF ( $_.strFileName -like "CHD3*" -and $_.Genre -like "*Animation*" ) { "B3" }
ELSEIF ( $_.strFileName -like "CHD3*" ) { "B5" }
ELSEIF ( $_.strFileName -like "CHD4*" ) { "B9" }
ELSEIF ( $_.strFileName -like "CMDA*" ) { "C1" }
ELSEIF ( $_.strFileName -like "CMDB*" ) { "C2" }
ELSEIF ( $_.strFileName -like "MTRA*" ) { "D3" }
ELSEIF ( $_.strFileName -like "MTRB*" ) { "E3" }
ELSEIF ( $_.strPath -like "*\Bonus\*" ) { "SF" }
ELSE { "F1" } }),({ IF ( $_.strPath -like "*\Movies\*" ) { $_.premiered}
ELSEIF ( $_.C05 -eq "1601-01-01" ) { $_.premiered }
ELSE { $_.C05 } }),strFileName )


$chan | ForEach-Object { 

$chn = @()

IF ( Test-Path "$schedule\Channels\$chanpath" ) { }
ELSE { New-Item "$schedule\Channels\$chanpath" -ItemType Directory }

IF ( $_.strPath -like "*Shows\*" ) { IF ( $_.strTitle -eq "DreamWorks Dragons" -and $_.strPath -like "*Riders of Berk*" ) { $tit = "Dragons: Riders of Berk" }
ELSEIF ( $_.strTitle -eq "DreamWorks Dragons" -and $_.strPath -like "*Defenders of Berk*" ) { $tit = "Dragons: Defenders of Berk" }
ELSEIF ( $_.strTitle -eq "DreamWorks Dragons" -and $_.strPath -like "*Race to the Edge*" ) { $tit = "Dragons: Race to the Edge" }
ELSEIF ( $_.strTitle -eq "The Super Mario Bros. Super Show!" -and $_.strPath -like "*Super Mario Bros. 3*" ) { $tit = "The Adventures of Super Mario Bros. 3" }
ELSEIF ( $_.strTitle -eq "The Super Mario Bros. Super Show!" -and $_.strPath -like "*Super Mario World*" ) { $tit = "Super Mario World" }
ELSEIF ( $_.strTitle -match "Sabrina: The Animated Series" -and $_.strPath -match "Secret Life" ) { $tit = "Sabrina's Secret Life" }
ELSEIF ( $_.strTitle -match "Plastic Man" -and $_.strPath -match "Baby Plas" ) { $tit = "The Plastic Man/Baby Plas Super Comedy Show" }
ELSEIF ( $_.strTitle -match "Legend Quest" -and $_.strPath -match "Masters of Myth" ) { $tit = "Legend Quest: Masters of Myth" }
ELSEIF ( $_.strTitle -match "Captain Underpants" -and $_.strPath -match "In Space" ) { $tit = "The Epic Tales of Captain Underpants in Space!" }
ELSEIF ( $_.strTitle -match "Harvey Kids" -and $_.strPath -match "Harvey Girls" ) { $tit = "Harvey Girls Forever!" }
ELSEIF ( $_.strTitle -match "Spirit: Riding Free" -and $_.strPath -match "Riding Academy" ) { $tit = "Spirit: Riding Free - Riding Academy" }
ELSEIF ( $_.strTitle -match "Spirit: Riding Free" -and $_.strPath -match "Pony Tales" ) { $tit = "Spirit: Riding Free - Pony Tales" }
ELSEIF ( $_.strTitle -match "Tales of Arcadia" -and $_.strPath -match "Trollhunters" ) { $tit = "Trollhunters: Tales of Arcadia" }
ELSEIF ( $_.strTitle -match "Tales of Arcadia" -and $_.strPath -match "3Below" ) { $tit = "3Below: Tales of Arcadia" }
ELSEIF ( $_.strTitle -match "Tales of Arcadia" -and $_.strPath -match "Wizards" ) { $tit = "Wizards: Tales of Arcadia" }
ELSEIF ( $_.strTitle -match "Tales of Ladybug" -and $_.strPath -match "Tales from Paris" ) { $tit = "Miraculous: Tales from Paris" }
ELSEIF ( $_.strTitle -match "Tales of Ladybug" -and $_.strPath -match "Zag Chibi" ) { $tit = "Miraculous Zag Chibi" }
ELSEIF ( $_.strTitle -match "Trolls" -and $_.strPath -match "TrollsTopia" ) { $tit = "Trolls: TrollsTopia" }
ELSE { $tit = $_.strTitle }
$pth = $_.C18


IF ($_.C09 -eq 0) { $showid = $_.idshow 
$runtime= [int](import-CSV "$schedule\shows.csv" | Where-Object { $_.idshow -eq "$showid" } | Select -ExpandProperty duration) }
ELSE { $runtime += ([int]$_.C09) }

}
ELSE { $tit = $_.C00
$pth = $_.C22
$runtime = $_.C11 }

IF ( ( $bby + $chd1 + $chd2 + $chd3 + $cmda + $cmdb + $mtra + $mtrb + $docu + $nue + $rrn + $tgr + $bng ) -contains $pth ) { }
ELSE { $chn += ('#EXTINF:-1,'+$tit+'
'+$pth+'
')
IF ( ([int]$runtime) -le 600 ) { $chn += ('#EXTINF:-1,Bumper
'+( $videos | Where-Object { "$_" -like "*\Bumpers\*" } | Get-Random )) }
ELSE { $chn += ('#EXTINF:-1,Bumper
'+( $videos | Where-Object { "$_" -like "*\Bumpers\*" } | Get-Random )+'
#EXTINF:-1,Commercial
'+( $videos | Where-Object { "$_" -like "*\Commercials\*" -or "$_" -like "*\Previews\*" -or "$_" -like "*\Fillers\*" } | Get-Random )+'
#EXTINF:-1,Bumper
'+( $videos | Where-Object { "$_" -like "*\Bumpers\*" } | Get-Random ) ) }

IF ($_.playcount -ge 1) { $rrn += $chn }
ELSE { $nue += $chn } } }

IF ( $nue.count -gt 0 ) { Add-Content -Force -Path "$schedule\Channels\$chanpath\New Episodes.m3u" -Value $nue }
ELSE { }
IF ( $rrn.count -gt 0 ) { Add-Content -Force -Path "$schedule\Channels\$chanpath\Reruns.m3u" -Value $rrn }
ELSE { }

# Back to episodes
}
})

#Get-ChildItem "$schedule\Channels" -Recurse -Directory | Where-Object { $channelsprocessed -notcontains $_.Name } | Remove-Item -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue

    # -----Now Playing-----
    
Get-ChildItem "$kodi\library\video\TV Shows\KodiTV" -Force -File | Where-Object { $_.Name -ne "index.xml"} | ForEach-Object { IF ( Test-Path ("$schedule\Channels\$_" -replace ".xml","") ) { }
ELSE { Remove-Item -literalpath $_.FullName -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue } }

@(Get-ChildItem "$schedule\Channels" -Recurse -Directory).ForEach({
    
    $channel = $_.Name

@(Get-ChildItem -literalpath $_.FullName -File | Where-Object { $_.Extension -notlike "*md5" } ).ForEach({

$firstep = Get-Content -literalpath $_.FullName | Where-Object { "$_" -like "*mkv*" -and "$_" -notlike "*\Previews\*" -and "$_" -notlike "*\Bumpers\*" } | Select -First 1

IF (  "Kids|Toonzai|Panda|Vortexx|Animation Domination|TGIF" -match $channel ) { }
ELSE { $guide = Get-Content -literalpath $_.FullName | Select -Skip 1

DO {
$guide = $guide | Select -Skip 1

} UNTIL ( (( $guide | Select -First 1 ) -notlike "*Commercial*" -and ( $guide | Select -First 1 ) -notlike "*Bumper*" -and ( $guide | Select -First 1 ) -like "*EXTINF*") -or $guide.count -le 0 )

@('',$guide) | Out-File -literalpath $_.FullName -Encoding UTF8
}
})

$chan = @()
Get-ChildItem "$schedule\Channels\$_" | Sort -Property Name | ForEach-Object { $chan += Get-Content -literalpath $_.FullName }

IF ( "Kids|Toonzai|Vortexx|Panda" -match $_.Name ) { $order = 00 }
ELSEIF ( "Ion|Syfy|Excelsior!|Magik|Chiller" -match $_.Name ) { $order = 40 }
ELSEIF ( "Cartoon Planet" -match $_.Name ) { $order = 05 }
ELSEIF ( "HBO|Fox|Disney+|ABC|Netflix" -match $_.Name ) { $order = 30 }
ELSEIF ( "Comedy Central|Hulu|LMAO" -match $_.Name ) { $order = 25 }
ELSEIF ( "ABC Family|NBC|Laff" -match $_.Name ) { $order = 27 }
ELSEIF ( "Adult Swim|Toonami|Crunchyroll|The Anime Network|Funimation Channel" -match $_.Name ) { $order = 20 }
ELSEIF ( "Disney Junior" -match $_.Name ) { $order = 10 }
ELSEIF ( "Cartoon Network|Nickelodeon|Disney XD" -match $_.Name ) { $order = 11 }
ELSEIF ( "Kids WB|Fox Kids|Netflix Kids|Discovery Kids" -match $_.Name ) { $order = 12 }
ELSEIF ( "Cartoon Network Too|SLAM!|Jetix" -match $_.Name ) { $order = 13 }
ELSEIF ( "Boomerang|The Bohbot Kids Network|Forever Kids" -match $_.Name ) { $order = 14 }
ELSEIF ( "The N|Disney Channel" -match $_.Name ) { $order = 15 }
ELSEIF ( "Spooky" -match $_.Name ) { $order = 16 }
ELSE { $order = 30 }

Test-Path "$kodi\library\video\TV Shows\KodiTV\$_.xml"

IF ( Test-Path "$kodi\library\video\TV Shows\KodiTV\$_.xml" ) { '<node order="'+"$order"+'" type="folder">
    <label>'+[string](($chan | Where-Object { "$_" -like "*EXTINF*" } | Select -First 1).replace("#EXTINF:-1,",""))+'</label>
    <path>'+"$schedule\Channels\$_"+'</path>
    <icon>'+"$logopath\$_"+'.png</icon>
</node>' | Out-File "$kodi\library\video\TV Shows\KodiTV\$_.xml" -Encoding UTF8 }
ELSE { '<node order="'+"$order"+'" type="folder">
    <label>'+"$_"+'</label>
    <path>'+"$schedule\Channels\$_"+'</path>
    <icon>'+"$logopath\$_"+'.png</icon>
</node>' | Out-File "$kodi\library\video\TV Shows\KodiTV\$_.xml" -Encoding UTF8 }
})

Write-Host "Done with that"
Reply
Here's a simplified version that does what it's supposed to do and has far fewer bells and whistles (such as commercials). Just run this when your computer starts up.
 
Code:
# Pre-Requisites
    # Save this script with UTF-8 BOM encoding or you may experience some problems when titles or files that have unusual characters
    # You will need SQLite3. It is free
        # https://www.sqlite.org/index.html

# This script will only handle episodes. It will not--at present--add movies to playlists unless they are considered s00 episodes
    # Sort order is "New Content -- Unwatched Episodes -- Repeats" with each section shuffled
        # Additionally you'll notice that I have things like "chd3" "chd2" etc. That's my own personal sorting scheme to create programming blocks. You can use it if you want to take advantage of that, but it isn't a requirement
            # mtrb = live action dramas
            # mtra = anime and action-oriented adult animation
            # cmdb = animated comedies
            # cmda = live action adult comedy
            # chd2 = live action children's comedies
            # chd3 = child-oriented anime and action cartoons (or shows like Power Rangers)
            # chd1 = children's animation
            # bby = preschool shows
        # I would recommend just creating a different channel for different genres or formats, however.
    # When you see a section like "strPath -like "*\Together\*", that is just how I separate material my wife wants to watch with me from content I will watch on my own. Don't worry about it

$schedule = "C:\Users\user\Documents\ChannelMaker" #Path to where you want the script to place m3u files. Not in your Kodi directory. I recommend a "Channels" folder in your documents
$sqlite3 = "C:\Users\user\Documents\ChannelMaker" #Path to SQLite3.exe
$kodi = "C:\Users\user\Documents\ChannelMaker" #Path to your Kodi Userdata folder
$logos = "C:\Users\user\Documents\ChannelMaker" #Path to the folder where you store your logos. The script expects png files
$year = 9999 #If you want new releases to take priority over older unwatched content, put the year you'd like new content to start from here. If you don't want this, leave it as 9999

#Commma separated list of channels you wish to generate. Exact names only. Do not forget your quotation marks
$channels = @("Nickelodeon","Cartoon Network","Disney Channel","SyFy","Magik","Chiller","Excelsior!","TV Land","Adult Swim","Anime Network","Kodi TV")

# You don't need to touch anything below this point unless you're comfortable with Powershell and want to adjust sort order or generate specific rules for channels

Remove-Item "$schedule\MyVideos121.db" -Force
Copy-Item "$kodi\Database\MyVideos121.db" -Destination "$schedule\MyVideos121.db" -Force

& "$sqlite3" -safe -header -csv "$schedule\MyVideos121.db" "select * from episode_view;" > "$schedule\episodes.csv"

$episodes = import-CSV "$schedule\episodes.csv" | Where-Object { $_.playcount -lt 1 } | Group-Object -Property strTitle,({IF ( $_.strPath -like "*\Together\*" ) { "Together" }
ELSE { "Solo" } }) | ForEach-Object { $_.Group | Sort -Property c05,c12,c13 | Select -First 1 }

IF ( Test-Path "$kodi\library\video\TV Shows\KodiTV" ) { }
ELSE { New-Item "$kodi\library\video\TV Shows\KodiTV" -ItemType Directory }

$channels.ForEach({
$channel = $_

# This is where specific channel rules can be customized if you want to take it that far. Use mine as examples

IF ( $channel -eq "SyFy" ) { $chanfil = '$_.genre -match "Science Fiction|SciFi" -and $_.genre -notmatch "Kids|Animation|Anime"' }
ELSEIF ( $channel -eq "Magik" ) { $chanfil =  '$_.genre -match "Fantasy" -and $_.genre -notmatch "Kids|Animation|Anime"' }
ELSEIF ( $channel -eq "Chiller" ) { $chanfil =  '$_.genre -match "Horror" -and $_.genre -notmatch "Kids|Animation|Anime"' }
ELSEIF ( $channel -eq "Excelsior!" ) { $chanfil =  '$_.genre -match "Superhero" -and $_.genre -notmatch "Kids|Animation|Anime"' }
ELSEIF ( $channel -eq "TV Land" ) { $chanfil =  '$_.genre -match "Comedy" -and $_.genre -notmatch "Kids|Animation|Anime"' }
ELSEIF ( $channel -eq "Adult Swim" ) { $chanfil =  '$_.genre -match "Comedy" -and $_.genre -match "Animation" -and $_.genre -notmatch "Kids|Anime"' }
ELSEIF ( $channel -eq "Anime Network" ) { $chanfil =  '$_.genre -match "Anime"' }
ELSEIF ( $channel -eq "Kodi TV" ) { $chanfil =  '$_.genre -notmatch "Kids|Animation|Anime|Science Fictoin|SciFi|Fantasy|Superhero|Comedy|Horror"' }
ELSE { $chanfil = '$_.studio -match $channel' }

IF ( Test-Path "$schedule\Channels\$channel" ) { }
ELSE { New-Item "$schedule\Channels\$channel" -ItemType Directory }

$episodes | Where-Object { ( invoke-expression $chanfil ) } | Sort-Object -Property ({IF ( ($_.c05).substring(0,4) -ge $year ) { "A" }
ELSE { "B" } }),({IF ($_.strFileName -match "mtrb") {"mtrb"}
ELSEIF ($_.strFileName -match "mtra") {"mtra"}
ELSEIF ($_.strFileName -match "cmdb") {"cmdb"}
ELSEIF ($_.strFileName -match "cmda") {"cmda"}
ELSEIF ($_.strFileName -match "chd2") {"chd3"}
ELSEIF ($_.strFileName -match "chd3") {"chd2"}
ELSEIF ($_.strFileName -match "chd1|bby") {"chd1"}
ELSEIF ($_.strFileName -match "bby") {"bby"}
ELSE { "othr" }}),{Get-Random} | ForEach-Object { IF ( $channel -eq "Panda" ) { $_ }
ELSEIF ( $_.strPath -notlike "*\Together\*" ) { $_ }
ELSE { } } | ForEach-Object { ('#EXTINF:-1,'+$_.strTitle)
$_.c18} | Out-File "$schedule\Channels\$channel\$channel.m3u" -Encoding UTF8 -Force

'<node order=00 type="folder">
    <label>'+"$channel"+'</label>
    <path>'+"$schedule\Channels\$_"+'</path>
    <icon>'+"$logos\$channel"+'.png</icon>
</node>' | Out-File "$kodi\library\video\TV Shows\KodiTV\$channel.xml" -Encoding UTF8

})

Get-ChildItem "$schedule\Channels" -Directory | Where-Object { $channels -notcontains $_.Name } | Remove-Item -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem "$kodi\library\video\TV Shows\KodiTV" -File | Where-Object { ($channels -notcontains ($_.Name).replace(".xml","")) -and $_.Name -ne "index.xml" } | Remove-Item -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue
Reply
(2024-01-04, 12:51)CodyLane Wrote:
(2024-01-04, 08:51)Rouzax Wrote: I fully agree, but it also looks like the popularity of Kodi is winding down in this age of streaming.
Just looking at the forums the activity is way down over years ago.

I should have a working zip file at home, when I'm back I'll load that in GitHub so it stays up.
Will be somewhere next week.
Thank you VERY much! 

Really sucks that interest in Kodi is waning. I wonder if it might be a better idea to just "go back" a few versions? I originally started out with 17. Only reason I updated was because I know nothing about how any of this works - so I'm always guessing the newest is best? 

However, losing MAJOR functionality with the loss of addons really sucks. Also, another guru pointed out that Kodi lost its Android group, and I use Kodi solely on that platform - so that's not good. 

Ah well... I am SO INSANELY THANKFUL to the Kodi developers for what they've provided me - so very much hoping things turn back around. 

Possibly I'm paranoid, but I like having my birds in hand. And Kodi is still king when it comes to managing my own catalog.

This is the version I have running.
https://github.com/Rouzax/script.lazytv/...di-V21-Fix

This is a combination of the versions that have floated around here and is working for me. I'm no python developer, so no guarantees.
Reply
@Kriven - given their size, it might be better to host those scripts on a pastebin site and link to them there.
To make access to them more manageable, and to give easier downloading capabilities.

I'd suggest not using our paste site as those automatically expire after a period of time, but some of the larger general paste sites can host stuff indefinitely if set correctly on upload.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
  • 1
  • 57
  • 58
  • 59
  • 60(current)
  • 61

Logout Mark Read Team Forum Stats Members Help
LazyTV - an unwatched TV Show playlist generator4