Do not set dates that are before the Unix Epoch time

Hi Guys,

I have had to rebuild my Kodi library when i decided my upgrade to Kodi 17 was premature. I will wait for more bug fix releases…

I have a little script i wrote that sets the date of the episode filenames to the air date but every now and then, Sonarr goes through the whole library and sets those same dates.

This is fine except for shows that aired before the Unix Epoch date (January 1st 1970). Kodi doesn’t like that date at all and basically anything that has aired before that date (like the 1967 Batman show) is always at the top of the list in recently added shows.

In my script, whenever i see an airdate in the nfo that is earlier than 1970, i just set the year to 1970 but keep the same month and day. That fixes the problem of Kodi setting the dateadded to something invalid.

This probably doesn’t affect a lot of people but it is a 12 second fix so it would be appreciated :slight_smile:

Thanks!

Where is Sonarr setting this date, on the file itself or in the metadata?
If it aired before 01/01/1970 what date do you expect to be used? I see you’re changing just the year, which works for you, but might not for others.

Sounds to me like an issue in kodi, and should be fixed there. Unix timestamp is an signed integer since jan 1st 1970, negative numbers are before that date.

And yes, that means that it will overflow when 2038 comes around, at least for systems still using 32-bit signed integers.

Yeah the file itself.

I set the day and month the same as the original air date but put the year as 1970 so i don’t get the issue in Kodi. That way if i sort by date added (aired date) those episodes are not at the top of the list.

I figured i would ask here first since you guys are way more agreeable than some of the Kodi devs…

But i understand that it may not be wanted since it’s a dirty workaround…

In Kodi, “date added” is not the same piece of metadata as “air date”, obviously.

Perhaps you could make a custom playlist using Kodi’s “FIRST AIRED” field to display recently aired episodes (say within the past 14 days). This would prevent Batman from being forever at the top of your list. Then turn off Sonarr’s “Change File Date” setting since clearly you understand it doesn’t work for your pre-1970 files. Then you don’t need to ask anyone for help fixing a “problem” that only exist because you created it :sunglasses:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.