Welcome, Guest
Python Scripts for ComicRack

TOPIC: Smart List using Release Date and StatsLastReleasedTime

Smart List using Release Date and StatsLastReleasedTime 2 years 7 months ago #42025

  • jkthemac
  • jkthemac's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 766
  • Thank you received: 253
  • Karma: 55
The recent question about a Smart List for the last episode reminded me I had never cracked how to use the {StatsLastReleasedTime} in a Smart List so today I tried to work out why those scripts never seemed to work

I finally have an answer.

Firstly the files without released dates confuse the issue because the {StatsLastReleasedTime} is based on the last filled in [Release Date]. So if only the first comic in a volume had a filled in [Released Date] that would become the {StatsLastReleasedTime}.

Secondly the format of [Release Date] is not as I expected and some trial and error reveals it to be:

01/01/2000 00:00:00

With these elements in place I have finally created a Smart List that displays only the last six months of any specific comic run.

Name "Last Six Months"
Match All
{
    Not [Released] equals "",
    Match Any
    {
        Match All
        {
            [Expression] is true "int(str({StatsLastReleasedTime})[3:5]) >= 6",
            [Expression] is true "int(str({StatsLastReleasedTime})[6:10]) == int(str({ReleasedTime})[6:10])",
            [Expression] is true "int(str({StatsLastReleasedTime})[3:5]) - 5 <= int(str({ReleasedTime})[3:5])"
        },
        Match All
        {
            [Expression] is true "int(str({StatsLastReleasedTime})[3:5]) <= 5",
            Match Any
            {
                Match All
                {
                    [Expression] is true "int(str({ReleasedTime})[6:10]) ==  int(str({StatsLastReleasedTime})[6:10]) - 1",
                    [Expression] is true "int(str({StatsLastReleasedTime})[3:5]) + 7 <= int(str({ReleasedTime})[3:5])"
                },
                Match [Expression] is true "int(str({ReleasedTime})[6:10]) ==  int(str({StatsLastReleasedTime})[6:10])"
            }
        }
    }
}

This works by using [Release Date] as a string and then slicing that string for a year or month and turning it back into an integer. That integer can then be used in calculations and expressions.

So the pseudo code of the above would read:

Name "Last Six Months"
In Library
For all comics that have a release date
       When Last Month >= 6
            Match
            	All comics in same year as final year
            	All Comics released after Month - 5 
       When Last Month < 6
            Match Both
               		All Comics for previous year,
                    	All Comics released after Month + 7 
                  And
                	All comics in same year as final year
Last Edit: 2 years 7 months ago by jkthemac.
The administrator has disabled public write access.

Smart List using Release Date and StatsLastReleasedTime 2 years 7 months ago #42026

  • jkthemac
  • jkthemac's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 766
  • Thank you received: 253
  • Karma: 55
For a simpler script you can match the whole unsliced string:

Name "Released On"
Match [Expression] is true "str({ReleasedTime}) == \"07/05/2008 00:00:00\""
Last Edit: 2 years 7 months ago by jkthemac.
The administrator has disabled public write access.

Smart List using Release Date and StatsLastReleasedTime 2 years 7 months ago #42027

  • jkthemac
  • jkthemac's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 766
  • Thank you received: 253
  • Karma: 55
You can match the sliced string with years:

Name "Last Released Year Equals"
Match All
{
    [Expression] is true "int(str({StatsLastReleasedTime})[6:10]) == int(2010)",
    Not [Released] equals ""
}

Or
Name "Released in Year"
Match All
{
    [Expression] is true "int(str({ReleasedTime})[6:10]) == int(2010)",
    Not [Released] equals ""
}
Last Edit: 2 years 7 months ago by jkthemac.
The administrator has disabled public write access.

Smart List using Release Date and StatsLastReleasedTime 2 years 7 months ago #42028

  • jkthemac
  • jkthemac's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 766
  • Thank you received: 253
  • Karma: 55
Or you can match the sliced date thus:
Name "Released On"
Match All
{
    [Expression] is true "str({ReleasedTime})[:10] == \"07/05/2008\"",
}
Last Edit: 2 years 7 months ago by jkthemac.
The administrator has disabled public write access.

Smart List using Release Date and StatsLastReleasedTime 2 years 7 months ago #42030

  • jkthemac
  • jkthemac's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 766
  • Thank you received: 253
  • Karma: 55
So a simpler script could be the last month of any comic run:
Which would include double shipped issues and point releases. Or indeed those annoying .INH type issues.
Name "Last Released Year / Month"
Match All
{
    [Expression] is true "int(str({ReleasedTime})[6:10]) == int(str({StatsLastReleasedTime})[6:10])",
    [Expression] is true "int(str({ReleasedTime})[3:5]) == int(str({StatsLastReleasedTime})[3:5])",
    Not [Released] equals ""
}
Last Edit: 2 years 7 months ago by jkthemac.
The administrator has disabled public write access.

Smart List using Release Date and StatsLastReleasedTime 2 years 7 months ago #42031

  • jkthemac
  • jkthemac's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 766
  • Thank you received: 253
  • Karma: 55
Here are the files for reference:


File Attachment:

File Name: ReleaseDat...ipts.zip
File Size:3 KB
The administrator has disabled public write access.
Time to create page: 0.184 seconds

Who's Online

We have 239 guests and 5 members online