User

WikiLucas00/word2recording

< User:WikiLucas00
Revision as of 15:06, 5 December 2021 by WikiLucas00 (talk | contribs) (Creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Find recordings for a given word

The following code snippet allows to quickly find recordings for a given word:

function word2recording(word) {
    var recordings = [];  // the list that will contain the recordings URL to be hotlinked
    // Limit = 10 can be changed in the url
    var url = "https://commons.wikimedia.org/w/api.php?action=query&format=json&origin=*&prop=imageinfo&generator=search&utf8=1&iiprop=url&gsrsearch=intitle:/LL-Q150+%5C%28fra%5C%29-%5B%5E-%5D*-"+mot+"%5C.wav/&gsrnamespace=6&gsrlimit=10&gsrwhat=text"

    $.getJSON(url, function(data) {
            var pages = data.query.pages;
            for (var page in pages){
                var url = pages[page].imageinfo[0].url;
                recordings.push(url);
            };
    });
}