User

Difference between revisions of "WikiLucas00/word2recording"

< User:WikiLucas00

(Creation)
 
 
Line 1: Line 1:
 
== Find recordings for a given word ==
 
== Find recordings for a given word ==
The following code snippet allows to quickly find recordings for a given word:
+
The following JQuery code snippet allows to quickly find recordings for a given word:
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
 
function word2recording(word) {
 
function word2recording(word) {

Latest revision as of 18:47, 20 November 2022

Find recordings for a given word

The following JQuery 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);
            };
    });
}