@@ -426,7 +426,7 @@ bool YT_DLP::CheckNonYtPlaylistURL(CString url)
426426 return false ;
427427}
428428
429- bool YT_DLP::Parse_Playlist (const CStringW& url , CFileItemList& playlist, int & idx_CurrentPlay)
429+ bool YT_DLP::Parse_Playlist (const CStringW& pls_url , CFileItemList& playlist, int & idx_CurrentPlay)
430430{
431431 // get a copy of the settings
432432
@@ -440,7 +440,7 @@ bool YT_DLP::Parse_Playlist(const CStringW& url, CFileItemList& playlist, int& i
440440 // run yt-dlp.exe
441441
442442 CStringA buf_out;
443- bool ok = RunYtDlp (ydl_path, L" --flat-playlist --dump-single-json" , url , buf_out);
443+ bool ok = RunYtDlp (ydl_path, L" --flat-playlist --dump-single-json" , pls_url , buf_out);
444444 if (!ok) {
445445 return false ;
446446 }
@@ -457,12 +457,24 @@ bool YT_DLP::Parse_Playlist(const CStringW& url, CFileItemList& playlist, int& i
457457 return false ;
458458 }
459459
460+ playlist.clear ();
461+ idx_CurrentPlay = -1 ;
462+
460463 for (const auto & entry : entries->GetArray ()) {
461464 CStringW url;
462465 if (!getJsonValue (entry, " url" , url)) {
463466 continue ;
464467 }
465468
469+ if (idx_CurrentPlay < 0 ) {
470+ CStringW id;
471+ if (getJsonValue (entry, " id" , id)) {
472+ if (pls_url.Find (id) > 0 ) {
473+ idx_CurrentPlay = (int )playlist.size ();
474+ }
475+ }
476+ }
477+
466478 CStringW title;
467479 getJsonValue (entry, " title" , title);
468480 int duration = 0 ;
@@ -471,7 +483,14 @@ bool YT_DLP::Parse_Playlist(const CStringW& url, CFileItemList& playlist, int& i
471483 playlist.emplace_back (url, title, UNITS * duration);
472484 }
473485
474- return playlist.size () > 0 ;
486+ if (playlist.size ()) {
487+ if (idx_CurrentPlay < 0 ) {
488+ idx_CurrentPlay = 0 ;
489+ }
490+ return true ;
491+ }
492+
493+ return false ;
475494}
476495
477496bool YT_DLP::SetFormats (const rapidjson::Document& doc)
0 commit comments