# How to create a list of videos and choose the day each video will be showed

Hello everyone. Here I am again suffering for days for a simple thing. I hope someone can help me.

I am creating an app where the user has to watch 5 videos every day (from a list of xx videos) to get a revenue (before someone accuse me, it is not an earning app, the videos are from partners who pay for view and the user get discount in their shops when they watch the videos). The list of videos is hosted in Firebase real time database.
All the users must get the same 5 videos every day, and if yesterday the users got the 5 first videos, today they must watch the 6-10 videos, until the list is finished. Then the users must get the videos from the beginnin of the list again.

For now I set the app to show always the first 5 videos of the list. I canâ€™t find a way to show diferent videos every day and restart when the list of videos is finished.

what happens for example on the third day, if a user on the second day does not watch any video?
or what happens, if he watches only 1 video instead of all 5?

this is some simple mathâ€¦
on day 1 show video 1-5
on day 2 show video 6-10
you only have to store the day number in TinyDB and do some calculationâ€¦

Taifun

1 Like

The user will get his bonus only after he watches the 5 videos. This part is already working well.

If the user does not watch the videos on day 2, he will just not receive the bonus related to that day. Then in the third day he will receive the bonus related to day 3 normally.

In theory I know that. But how can I show to the user the 5 videos that must be watched that day? If I had to show the videos in a specific date it would be easy. I save the list of videos and the date they must be watched in firebase. When the app of the user initialize I check if the date is equal using clock component, and if it is, the videos are shown. But this will be dynamic, if there are 10 videos, the videos will be repeated each 2 days. If there are 100 videos, the videos wonâ€™t be repeated for 20 days.
How can I make this work? I canâ€™t see a way to make it work.

I think if you use two tinydb yoi can overcome from this problem. One for current day counter, another for total video counter.

If the current day is not equal to saved day reset the count to zero in tinydb1 and start to show ads. Upon every video over, save the counter in current day and in the total counter add with existing value of tinydb2

In tinydb1 if the counter becomes 5 then you can reward him

1 Like

I will test it, but I believe this solve my problem. Thank you a lot <3

1 Like

So with the help of second tinydb counter you can show the ad or video orderly from the lists of videosâ€¦ i mean if it shows no.5 mean you can show 6th videoâ€¦ even if user miss to see 5 video but saw only 3 only mean also no problemâ€¦

However tinydb1 will go zero if the dates are not equalâ€¦ based on tiny2 you can show the next next videos, i believeâ€¦

Once blocks created i am sure this will work , if you donâ€™t want tinydb you can use any database with same algorithmâ€¦

If the tinydb2 counter become equal to length of the total video list then reset the counter value to one so you will loop

1 Like

Could you send me your paypal in DM? I want to send you 5\$ but I canâ€™t message you. donâ€™t know why since I have already messaged you before.