Module:Classement musical/Données
Aller à la navigation
Aller à la recherche
La documentation pour ce module peut être créée à Module:Classement musical/Données/doc
-- Ce module contient des données pour le [[Module:Classement musical]]. local cfg = { albumData = 'Module:Classement musical/Données/Album', singleData = 'Module:Classement musical/Données/Single', albumDetectCat = 'Catégorie:Albumchart utilisé avec des paramètres manquants', singleDetectCat = 'Catégorie:Singlechart utilisé avec des paramètres manquants', rowHeader = 'rowheader', publishDate = 'en ligne le', accessDate = 'consulté le', accessDatePrefix = 'Consulté le', errorPrefix = 'Erreur :', noChartError = 'Classement « %s » introuvable', noParamsError = 'Paramètre(s) « %s » manquant(s)', } -- Convert string to a percent ANSI encoding rather than UTF-8 encoding. -- Function adapted from [[en:Module:WLink.ansiPercent]]. local function ansiPercentEncoder(text) local k, s local r = text:gsub(" ", "+"):gsub("&", "%%26") for i = mw.ustring.len(r), 1, -1 do k = mw.ustring.codepoint(r, i, i) if k <= 32 or k > 126 then if k > 255 then s = mw.ustring.sub(r, i, i) if k > 2047 then s = string.format("%%%2X%%%2X%%%2X", s:byte(1, 1), s:byte(2, 2), s:byte(3, 3)) else s = string.format("%%%2X%%%2X", s:byte(1, 1), s:byte(2, 2)) end else s = string.format("%%%2X", k) end r = string.format("%s%s%s", mw.ustring.sub(r, 1, i - 1), s, mw.ustring.sub(r, i + 1)) end end r = mw.ustring.gsub(r, '^%*', '%%2A') return r end -- Convert string to a hyphen separator encoding. local function hyphenEncoder(text) return text:gsub(" ", "-"):lower() end -- Note: -- * Keyless entries represent the required parameters. -- * The definition order of these parameters is important. -- * Set 'encoder' to encode parameter entries in the URL. -- * Set 'optionalParams' for charts with no parameter in the link or/and the title. local formats = { -- Parameters required for the link or/and the title. hungMedienSong = { 'artiste', 'chanson', encoder = ansiPercentEncoder }, hungMedienAlbum = { 'artiste', 'album', encoder = ansiPercentEncoder }, billboard = { 'artiste', encoder = hyphenEncoder }, artist = { 'artiste' }, date = { 'date' }, yearAndWeek = { 'année', 'semaine' }, weekAndYear = { 'semaine', 'année' }, chartTrack = { 'année', 'année', 'semaine' }, chartId = { 'chartid' }, songId = { 'chansonid' }, yearAndChartId = { 'année', 'chartid' }, -- Parameters not required (for note insert only). yearAndWeekOption = { 'année', 'semaine', optionalParams = true } } return { cfg = cfg, formats = formats }