rleroi / stremio-anime

Discontinued Anime add-on for Stremio
0 stars 0 forks source link

Sorting Episodes #5

Closed BoredLama closed 5 years ago

BoredLama commented 5 years ago

I noticed your comment here: https://github.com/rleroi/stremio-anime/blob/master/server.js#L279

Stating:

// let's sort the episodes. // doesn't matter, for some reason stremio doesn't show the correct order

I know the reason for this, look here: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/meta.md#video-object

Episodes are sorted based on the released property, l think it should be a timestamp. If you set your released time (even a fake one) with even a 1 millisecond difference between the episodes, they will be ordered correctly.

BoredLama commented 5 years ago

I just checked, it's not a timestamp, the value for released should be in the form of: 2016-04-20T04:00:00.000Z

Example of creating such a string:

var currentTimestamp = Date.now();
var toDate = new Date(currentTimestamp);
var released = toDate.toISOString(); // will be: "2019-01-17T16:31:00.000Z"
rleroi commented 5 years ago

Thanks for this! It seems to be working if I put released: new Date(), the ISO string is probably returned when casting the Date as a string.