Project

General

Profile

playlist-data.cc.diff

Post 878 Ext. m3u playlist patch for CORE. - Jim Turner, March 18, 2019 03:57

View differences:

playlist-data.cc 2019-03-17 22:29:03.235779322 -0500
22 22
#include <stdlib.h>
23 23
#include <string.h>
24 24

  
25
#include "audstrings.h"
25 26
#include "runtime.h"
26 27
#include "scanner.h"
27 28
#include "tuple-compiler.h"
......
172 173
    if (entry->selected)
173 174
        m_selected_length -= entry->length;
174 175

  
176
    /* JWT: KEEP (DON'T OVERWRITE) ENTRY'S TITLE IF TUPLE'S TITLE IS NOT SET!
177
       (NEEDED FOR EXTENDED M3U PLAYLIST ITEMS TO KEEP THE TITLE!)
178
    */
179
    String Title = entry->tuple.get_str (Tuple::Title);
180
    if (! tuple.is_set (Tuple::Title))
181
        tuple.set_str (Tuple::Title, Title);
182

  
175 183
    entry->set_tuple (std::move (tuple));
176 184

  
177 185
    m_total_length += entry->length;
......
1045 1053
    if (! entry->decoder)
1046 1054
        entry->decoder = request->decoder;
1047 1055

  
1056
    const char * base;
1057
    const char * ext;
1058
    int isub_p;
1059
    uri_parse (request->filename, & base, & ext, nullptr, & isub_p);
1060
    int baselen = ext - base;
1048 1061
    if (! entry->tuple.valid () && request->tuple.valid ())
1049 1062
    {
1063
        int cuesetlength = entry->tuple.get_int (Tuple::Length);  // JWT:DON'T LET SCAN REPLACE CUESHEET-SET LENGTH, IF SET!
1064
        /* JWT: NEEDED FOR EXTENDED M3U PLAYLISTS - TO KEEP THE PLAYLIST TITLE FROM BEING OVERWRITTEN
1065
           BY THAT FROM THE CUESHEET!
1066
           * ONLY REPLACE ENTRY'S TITLE W/REQUEST'S TITLE IF CUESHEET AND THE ENTRY'S TITLE
1067
           IS STILL JUST THE FILENAME! (ACCOMPLISHED BY STUFFING THE CURRENT ENTRY'S TITLE
1068
           INTO THE REQUEST TUPLE BEFORE REPLACING ENTRY'S TUPLE W/REQUEST'S TUPLE)
1069
           THIS NEEDED TO ENSURE THAT A CUESHEET ENTRY'S TITLE IN A NON-EXTENDED M3U PLAYLIST
1070
           GETS (STAYS) OVERRIDDEN BY THE TITLE IN THE CUESHEET (PREVIOUSLY WE DIDN'T SUPPORT
1071
           CUESHEETS IN M3U PLAYLISTS).
1072
        */
1073
        String oldTitle = entry->tuple.get_str (Tuple::Title);
1074
        if (oldTitle && oldTitle[0] && isub_p > 0 && strncmp ((const char *) oldTitle, base, baselen))
1075
            request->tuple.set_str (Tuple::Title, oldTitle);
1076

  
1050 1077
        set_entry_tuple (entry, std::move (request->tuple));
1078
        if (cuesetlength > 0)  // JWT:MAKE SURE RECALCULATED LENGTH FROM CUESHEETS DOESN'T GET CLOBBERED!
1079
            entry->tuple.set_int (Tuple::Length, cuesetlength);
1080

  
1051 1081
        queue_update (Playlist::Metadata, entry->number, 1, update_flags);
1052 1082
    }
1053 1083