tubesync icon indicating copy to clipboard operation
tubesync copied to clipboard

{playlist_index} giving None instead of the index number

Open TommyRush opened this issue 5 years ago • 4 comments

Hi, I am doing something wrong and I am getting "None" instead of the index number for {playlist_index}. But, I am not sure why it's doing that

Example playlist https://www.youtube.com/playlist?list=PLj_Goi54wf0cZiSCqhKbCEHqd0pKVBZWt

I used this for the media format {playlist_index}_{yyyy_mm_dd}_{source}_{title}_{key}_{format}.{ext}

The example filename does have the index number correctly, so I assume it's not me typoing it 1_2021-06-03_empire_some-media-title-name_SoMeUnIqUiD_1080p-vp9-opus-60fps.mkv

But it doesn't when it downloads, this is the first file for me from the playlist None_2020-12-01_empire_keep-your-friends-close-but-your-enemies-closer-in-empire-of-sin-part-1_Mx4d8OliocI_vp9-opus-60fps.mkv

All the rest had the same None. I added it as a playlist and it does say YouTube playlist in the source type. I am using docker with tubesync 0.9.1 and it has youtube-dl version 2021.03.03

Thanks for making tubesync, it's been super helpful.

TommyRush avatar Jun 03 '21 18:06 TommyRush

I don't think you or TubeSync is doing anything wrong here. If I pick a random video from that playlist and keep the playlist context, for example:

https://www.youtube.com/watch?v=Mx4d8OliocI&list=PLj_Goi54wf0cZiSCqhKbCEHqd0pKVBZWt

and dump its metadata as JSON it has:

   ...
    "playlist": null,
    "playlist_index": null,
   ...

set. The playlist_index value isn't something TubeSync calculated, it's directly taken from the YouTube video metadata so this isn't something I can fix. This may be because TubeSync now has to retroactively populate video metadata and the playlist context is lost on videos.

I'll investigate this a bit further, but unfortunately the resolution may be that the playlist_index filename parameter gets removed if it's technically unable to be implemented now. TubeSync mostly just sits on top of whatever youtube-dl does.

Thanks for the issue and detailed report though!

meeb avatar Jun 04 '21 05:06 meeb

Sorry for the massive delay had some stuff come up.

That is interesting, I bet it's youtube-dl doesn't get the index unless you are specifically on the playlist (?list= instead of v=..&list=).

I don't know the best way to dump the metadata, so I tried this youtube-dl.exe -j https://www.youtube.com/watch?list=PLj_Goi54wf0cZiSCqhKbCEHqd0pKVBZWt which has values for playlist_index

TommyRush avatar Jun 13 '21 19:06 TommyRush

I've poked into this a little more and this broke with the fix for rate limiting for indexing when closing #38. The way TubeSync works now is it indexes only the video IDs on a channel every X hours, then if a new video ID is found mark it to be fully indexed for metadata just once later. This means that "checking for new videos" is significantly lighter and faster, however the playlist_index data is only available when doing a "deep" crawl which is now explicitly not done. If you pick a random video on your playlist then youtube-dl.exe -j https://youtube.com/watch?v=videoid even with ?list=whatever on it the URL the playlist_index is not set, resulting in the reported behaviour in this issue.

The only possible way this could be resolved (without breaking indexing again) is some attempt to pull the playlist_index out of the initial "are there any new videos" scan and attempt to merge metadata later on with the deep scan. It may be possible but requires further checking.

meeb avatar Jun 14 '21 04:06 meeb

Closed / dupe of #142

meeb avatar Sep 04 '21 10:09 meeb