Local API: Extract playlists on the auto-generated "Music" channel#5250
Local API: Extract playlists on the auto-generated "Music" channel#5250FreeTubeBot merged 1 commit intoFreeTubeApp:developmentfrom
Conversation
PikachuEXE
left a comment
There was a problem hiding this comment.
Example playlist for no views
https://youtube.com/playlist?list=RDCLAK5uy_k5n4srrEB1wgvIjPNTXS9G1ufE9WQxhnA
Or keep finding one in https://www.youtube.com/music
| this.firstVideoId = result.items[0].id | ||
| this.playlistThumbnail = result.info.thumbnails[0].url | ||
| this.viewCount = extractNumberFromString(result.info.views) | ||
| this.viewCount = result.info.views.toLowerCase() === 'no views' ? 0 : extractNumberFromString(result.info.views) |
There was a problem hiding this comment.
suggestion (non-blocking): We have a few places in the code where we use extractNumberFromString and it ends up getting used as NaN. I get from an "API" level why NaN is an appropriate return value, but it is this behavior that ultimately results in us displaying NaN throughout the app. I'd recommend returning 0 instead of NaN from that function in both the not-string case and NaN parseInt case just to cover the swathe of edge cases more easily.
There was a problem hiding this comment.
While you are correct that in many places we don't handle NaN and just display it to the user, in other places we actually rely on it, so we know when to hide UI elements for example.
So we either need to create a separate wrapper function the converts the NaN to zero in the places where that is desired or add an extra parameter to control when the fallback should be zero.
Local API: Extract playlists on the auto-generated "Music" channel
Pull Request Type
Description
This pull request adds support for extracting and displaying playlists on the auto-generated system "Music" channel. Unlike #5241 which adds support for a whole category of channels, this pull request is only for one specific one.
I also noticed that some of the playlists listed there were showing
NaN viewson the playlists page, so I fixed that so it correctly shows0 viewswhen YouTube saysNo views.Screenshots
Testing
Open
https://www.youtube.com/musicin FreeTube and notice the playlists tab.Desktop