Download "top 100 videos" from YouTube channel or playlist, sorted by views-per-day#139
Download "top 100 videos" from YouTube channel or playlist, sorted by views-per-day#139deldesir wants to merge 9 commits into
Conversation
|
| time_uploaded = datetime.utcfromtimestamp(time_uploaded) | ||
| now = datetime.now() | ||
| # calculate views per day | ||
| days_since_publish = (now - time_uploaded).days |
There was a problem hiding this comment.
Can we force days_since_publish to be 1 at minimum (i.e. 1 day) to avoid divide-by-zero errors?
@deldesir please use a vividly descriptive variable/constant name. Possibly something like:
Likewise in future, we might need to consider:
|
|
@deldesir thanks for clarifying:
|
Yes, this is done automatically.
Done. Please see https://github.com/iiab/calibre-web/wiki/Home/_compare/8376933a218f164fa18f3cf378ce491501dd94e7...2222461e9ca347c017c0cf68173d4b61e3c02cc5
I agree. For this we'll need to know the approximate size of the videos before downloading them. |
This PR doesn't work with YouTube channels yet. I am working on it.
N/A
To eliminate "external" videos, I'll need to filter all videos based on their "uploader" ids. We should be covered once I am done supporting channels. |
Thanks for explaining: We can also defer that, as videos that originate "external to the channel" are generally a rare/corner case — that individual IIAB implementers can (and probably should!) manually/quickly solve on their own. |
|
@deldesir what should @EMG70 be testing to confirm this PR is solid-or-close? Also:
Thanks! |
Useful when other users are downloading videos or testing with lb-wrapper...
|
@holta, downloading top videos from channels now works. There is currently an issue with shorts being duplicated in xklb-metadata.db after their metadata has been updated. I work around this for now by filtering them. Hopefully, @chapmanjacobd can help resolve this so they can be included in top videos lists. @EMG70, please test this PR following the instructions found in https://github.com/iiab/calibre-web/wiki#setting-the-maximum-number-of-videos-to-download. You can test with playlists, playlists of playlists, or channels. |
--extra option make key metadata available without needing to download
|
SUDO IIAB-DIAGNOSTICS - http://sprunge.us/mqtZDA?en |
|
Thanks @EMG70 for the valuable feedback: As this PR (or similar!) needs to be tightened up with solid testing, and merged quickly after ~2 weeks now 👍 |
I am investigating... I'll be back with an explanation. |
|
Thanks @EMG70 for pointing out the issue. I don't understand yet what background limitations causing this, but I just fixed it by structuring the code better. This PR will be closed and remade in to smaller ones for clarity. Thanks for your patience. |
|
Is the issue related to playlists and channels with many videos? e.g. @EMG70's playlist with 151 videos? In comparison with playlists containing <= 50 videos? |
|
The issue is tied to the latest commit I made to align with xklb v2.5.018. This commit ensured the database was fully updated in a single Regarding the Ed's failed test, I suspect the issue is indeed related to playlists and channels with many videos. It worked for a small playlist of 18 videos (with MAX_VIDEOS_PER_DOWNLOAD = 3). |
|
Thanks for explaining. Please lay out different kinds of playlists/channels (or different kinds of sanity-tests?) that we can all help with — either revising or replacing these testing scenarios: |
|
Done in #97 (comment) |
|
FYI this PR #139 is being refactored, starting with smaller PRs like: |


🚀 Pull Request Overview:
This PR adds views-per-day to the metadata so videos can be sorted automatically based on the playlist. If the playlist contains more than 100, a bookshelf with the top 100 videos (based on their views per day) is created. For playlists with less than 100 videos, the sorting still happens automatically.
📋 Checklist:
📌 Testing scenarios:
See Issue #97
cc @EMG70