0

When I try to use Google Play's search functionality to find special characters such as "-", "." or "[" it doesn't filter results by these characters.

How can I search for songs and artists that contain special characters like these?

0

You can do this in JavaScript using the IndexedDB that Google Play uses. Just change out the "-" below with whatever string (including special characters) that you want to search for.

Currently it only searches the track and artist names. If you want it to also search the album, add t[4].includes(specialChar) to the if statement. If you want it to also search the genre, add the same thing but using 11.

(function () {
    const specialChar = "-"; 
    console.log("=====Songs and artists containing " + specialChar + ": =====");
    indexedDB.databases().then(info => {
        const name = info.find(db => db.name.indexOf("music_") === 0).name;
        indexedDB.open(name).onsuccess = e => {
            const t = e.target.result.transaction("tracks", "readwrite"); 
            t.oncomplete = () => {
                console.log("=====All tracks listed.=====")
            }
            t.objectStore("tracks").openCursor().onsuccess = e => {
                if (e = e.target.result) { 
                    let data = JSON.parse(e.value);

                    Object.values(data).forEach(t => {
                        if(t[1].includes(specialChar)
                        || t[3].includes(specialChar)) {
                            console.log(t[3] + " - " + t[1]);
                        }
                    });
                    e.continue();
                }
            }
        }
    }).catch(e => console.log(e));
})()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.