mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-22 19:23:21 +00:00
Updated the random movie logic concept.
This commit is contained in:
@@ -3,12 +3,15 @@ PseudoChannelRandomMovie
|
||||
|
||||
In order to get a better randomization by avoiding movie repeates,
|
||||
this class helps get a random movie based on its "lastPlayedDate".
|
||||
The function keeps grabbing random movies, checking the "lastPlayedDate",
|
||||
comparing it with todays date, and checking the delta against
|
||||
the user specified "TIME_GAP_MONTHS" (which defaults at 6 [months]).
|
||||
It stops and returns the first random movie that satisfies the condition.
|
||||
However, if it runs through every movie and no movie satifies the condition,
|
||||
it then simply returns any movie.
|
||||
A list of all the movies are passed into this class ordered by
|
||||
"lastPlayedDate". The function then runs through the array to
|
||||
find the first movie that satisfies the delta of "lastPlayedDate"
|
||||
and "TIME_GAP_MONTHS". Then a new array with the rest of the movies
|
||||
that satisfy the condition is created. From there a random movie
|
||||
is picked and returned. If however, the function hits the end of the
|
||||
array of movies and the condition is not satisfied (all movies have
|
||||
been played more recently than the "TIME_GAP_MONTHS"), a random movie
|
||||
is then returned.
|
||||
|
||||
For smaller movie libraries it'll be useful to calculate a reasonable
|
||||
"TIME_GAP_MONTHS".
|
||||
|
||||
Reference in New Issue
Block a user