Release LazyTV - an unwatched TV Show playlist generator
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


Messages In This Thread
Works just with TV shows? - by [2ge] - 2015-02-20, 09:05
Clone error - by flutleflakes - 2016-02-03, 21:24
LazyTV request :) - by syralk - 2016-02-11, 17:59
RE: LazyTV - an unwatched TV Show playlist generator - by Kriven - 2024-01-14, 13:58
[RELEASE] LazyTV - by Karnagious - 2014-03-29, 11:59
RE: [RELEASE] LazyTV - by EuphoricaL - 2014-03-30, 01:01
RE: [RELEASE] LazyTV - by Karnagious - 2014-03-31, 13:16
RE: [RELEASE] LazyTV - by liquidtoon - 2014-04-17, 14:23
RE: [RELEASE] LazyTV - by PatK - 2014-04-17, 18:20
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-20, 04:42
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-20, 12:18
RE: [RELEASE] LazyTV - by PatK - 2014-04-20, 17:49
RE: [RELEASE] LazyTV - by mtoddster - 2014-04-21, 01:35
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-21, 02:02
RE: [RELEASE] LazyTV - by thrak76 - 2014-04-23, 18:35
RE: [RELEASE] LazyTV - by psike - 2014-04-25, 17:46
RE: [RELEASE] LazyTV - by PatK - 2014-04-25, 22:23
Re: RE: [RELEASE] LazyTV - by bry - 2014-04-25, 22:24
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-26, 06:14
RE: [RELEASE] LazyTV - by psike - 2014-04-26, 11:23
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-26, 12:55
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-27, 16:17
RE: [RELEASE] LazyTV - by psike - 2014-04-27, 23:18
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-28, 01:48
RE: [RELEASE] LazyTV - by kiffmoore - 2014-04-28, 12:51
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-28, 15:49
RE: [RELEASE] LazyTV - by kiffmoore - 2014-04-28, 17:23
RE: [RELEASE] LazyTV - by psike - 2014-04-28, 22:41
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-29, 01:49
RE: [RELEASE] LazyTV - by Lunatixz - 2014-04-29, 01:54
RE: [RELEASE] LazyTV - by psike - 2014-04-29, 06:14
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-29, 09:20
RE: [RELEASE] LazyTV - by psike - 2014-04-29, 23:57
RE: [RELEASE] LazyTV - by Karnagious - 2014-04-30, 02:34
RE: [RELEASE] LazyTV - by psike - 2014-04-30, 22:24
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-01, 00:38
RE: [RELEASE] LazyTV - by psike - 2014-05-02, 08:27
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-02, 10:15
RE: [RELEASE] LazyTV - by psike - 2014-05-02, 10:27
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-02, 10:32
RE: [RELEASE] LazyTV - by psike - 2014-05-02, 10:37
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-02, 10:43
RE: [RELEASE] LazyTV - by psike - 2014-05-02, 11:12
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-02, 11:29
RE: [RELEASE] LazyTV - by psike - 2014-05-06, 12:03
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-06, 14:44
RE: [RELEASE] LazyTV - by psike - 2014-05-06, 15:22
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-06, 15:34
RE: [RELEASE] LazyTV - by psike - 2014-05-06, 20:22
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-07, 00:21
RE: [RELEASE] LazyTV - by hutton1494 - 2014-05-07, 00:57
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-07, 01:40
RE: [RELEASE] LazyTV - by psike - 2014-05-07, 05:35
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-07, 06:51
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-07, 15:18
RE: [RELEASE] LazyTV - by psike - 2014-05-07, 21:09
RE: [RELEASE] LazyTV - by psike - 2014-05-07, 23:17
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-08, 00:22
RE: [RELEASE] LazyTV - by psike - 2014-05-08, 05:59
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-08, 06:20
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-10, 09:41
RE: [RELEASE] LazyTV - by psike - 2014-05-10, 10:23
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-10, 11:19
RE: [RELEASE] LazyTV - by psike - 2014-05-10, 14:47
RE: [RELEASE] LazyTV - by Lunatixz - 2014-05-10, 20:22
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-11, 00:47
RE: [RELEASE] LazyTV - by Lunatixz - 2014-05-11, 01:12
RE: [RELEASE] LazyTV - by ridflea - 2014-05-15, 01:23
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 02:19
RE: [RELEASE] LazyTV - by ridflea - 2014-05-15, 03:27
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 04:11
RE: [RELEASE] LazyTV - by ridflea - 2014-05-15, 04:23
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 04:23
RE: [RELEASE] LazyTV - by ridflea - 2014-05-15, 04:25
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 04:29
RE: [RELEASE] LazyTV - by ridflea - 2014-05-15, 04:31
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 04:47
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 04:57
RE: [RELEASE] LazyTV - by ridflea - 2014-05-15, 05:56
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-15, 23:54
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-18, 00:34
RE: [RELEASE] LazyTV - by spectre4188 - 2014-05-19, 21:51
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-19, 23:38
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-23, 13:22
RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-24, 14:46
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-24, 15:12
RE: [RELEASE] LazyTV - by Martijn - 2014-05-24, 15:17
RE: [RELEASE] LazyTV - by Lunatixz - 2014-05-24, 15:26
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-24, 15:41
Re: RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-24, 15:49
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-24, 15:58
RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-24, 16:45
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-25, 00:10
RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-25, 02:22
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-25, 03:18
RE: [RELEASE] LazyTV - by tdhz77 - 2014-05-25, 07:34
Re: RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-25, 12:00
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-25, 12:35
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-25, 14:26
RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-25, 18:01
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-26, 00:04
Re: RE: [RELEASE] LazyTV - by Mafarricos - 2014-05-26, 02:01
RE: [RELEASE] LazyTV - by Skipmode A1 - 2014-05-28, 19:07
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-28, 23:57
RE: [RELEASE] LazyTV - by Skipmode A1 - 2014-05-29, 12:31
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-29, 13:38
RE: [RELEASE] LazyTV - by Skipmode A1 - 2014-05-29, 14:05
RE: [RELEASE] LazyTV - by Karnagious - 2014-05-29, 14:59
RE: [RELEASE] LazyTV - by Karnagious - 2014-06-15, 11:13
RE: [RELEASE] LazyTV - by BubbaLovesTv - 2014-07-21, 08:25
RE: [RELEASE] LazyTV - by Karnagious - 2014-07-21, 12:38
RE: [RELEASE] LazyTV - by BubbaLovesTv - 2014-07-22, 09:55
RE: [RELEASE] LazyTV - by Karnagious - 2014-07-22, 11:22
RE: [RELEASE] LazyTV - by BMStroh - 2014-08-04, 17:08
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-05, 00:06
RE: [RELEASE] LazyTV - by BMStroh - 2014-08-05, 22:56
RE: [RELEASE] LazyTV - by anarchybomb88 - 2014-08-06, 08:20
RE: [RELEASE] LazyTV - by BubbaLovesTv - 2014-08-06, 08:42
RE: [RELEASE] LazyTV - by aalwani - 2014-08-06, 11:17
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-06, 11:55
RE: [RELEASE] LazyTV - by echo - 2014-08-07, 15:18
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-07, 15:59
Re: RE: [RELEASE] LazyTV - by aalwani - 2014-08-08, 16:03
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-09, 04:23
RE: [RELEASE] LazyTV - by aalwani - 2014-08-09, 22:15
RE: [RELEASE] LazyTV - by aalwani - 2014-08-17, 18:24
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-18, 02:33
RE: [RELEASE] LazyTV - by un1versal - 2014-08-22, 09:55
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-22, 12:34
RE: [RELEASE] LazyTV - by dgcruzing - 2014-08-22, 12:53
RE: [RELEASE] LazyTV - by un1versal - 2014-08-22, 14:25
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-22, 15:20
RE: [RELEASE] LazyTV - by un1versal - 2014-08-22, 17:02
RE: [RELEASE] LazyTV - by Karnagious - 2014-08-23, 01:37
RE: [RELEASE] LazyTV - by un1versal - 2014-08-23, 12:19
RE: [RELEASE] LazyTV - by skimshady - 2014-10-27, 21:31
RE: [RELEASE] LazyTV - by Karnagious - 2014-10-27, 22:28
RE: [RELEASE] LazyTV - by arithine - 2014-10-30, 20:34
RE: [RELEASE] LazyTV - by zsleaf - 2014-11-26, 11:47
RE: [RELEASE] LazyTV - by Karnagious - 2014-11-26, 12:50
RE: [RELEASE] LazyTV - by zsleaf - 2014-11-27, 15:48
RE: [RELEASE] LazyTV - by Karnagious - 2014-11-27, 22:30
RE: [RELEASE] LazyTV - by zsleaf - 2014-11-28, 03:34
RE: [RELEASE] LazyTV - by Karnagious - 2014-11-28, 05:03
RE: [RELEASE] LazyTV - by zsleaf - 2014-11-28, 07:32
RE: [RELEASE] LazyTV - by Karnagious - 2014-11-28, 07:53
RE: [RELEASE] LazyTV - by Diskotechjam - 2014-12-07, 02:29
RE: [RELEASE] LazyTV - by Rumik - 2015-01-06, 17:11
RE: [RELEASE] LazyTV - by rjcogin - 2015-01-20, 18:21
RE: [RELEASE] LazyTV - by Karnagious - 2015-01-21, 01:14
RE: [RELEASE] LazyTV - by ramecex - 2015-02-08, 17:48
RE: [RELEASE] LazyTV - by onlyyou - 2015-02-12, 12:15
RE: [RELEASE] LazyTV - by Karnagious - 2015-02-17, 01:53
RE: [RELEASE] LazyTV - by Karnagious - 2015-02-17, 01:54
RE: [RELEASE] LazyTV - by ramecex - 2015-02-18, 00:24
RE: [RELEASE] LazyTV - by Karnagious - 2015-02-18, 00:57
RE: [RELEASE] LazyTV - by a6co1lostud - 2015-08-03, 17:53
RE: [RELEASE] LazyTV - by Karnagious - 2015-08-04, 02:14
RE: [RELEASE] LazyTV - by a6co1lostud - 2015-08-04, 14:52
RE: [RELEASE] LazyTV - by Karnagious - 2015-08-05, 00:38
RE: [RELEASE] LazyTV - by braz - 2015-08-06, 17:22
Lazy Tv - by Robertcm49 - 2023-01-25, 18:22
RE: Lazy Tv - by izprtxqkft - 2023-01-25, 18:34
RE: Lazy Tv - by Robertcm49 - 2023-01-26, 19:48
Lazy Tv - by DarrenHill - 2023-01-27, 17:25
Logout Mark Read Team Forum Stats Members Help
LazyTV - an unwatched TV Show playlist generator4