Module:The JoTS/Music

-- User Profile Random Music (rev. 3 Oct 2017 0:15) -- Because screw autoplaying music of the same song. Every. Single. Time. -- By "The JoTS"

--

local type = { CHIPTUNE = 0, GAME_OST = 1, MASHUP = 2, REMIX = 3  } local mood = {} -- To be implemented. Maybe.

local source = { ["plvpwaa"] = { name     = "Professor Layton vs. Phoenix Wright: Ace Attorney", link     = "w:c:aceattorney:Professor Layton VS Gyakuten Saiban Magical Mystery Music", release  = "2013", mediatype = type.GAME_OST },

["sonicmania"] = { name = "Sonic Mania", link = "w:c:sonic:Sonic Mania", release = "2017", mediatype = type.GAME_OST },

["pmd_eot"] = { name = "Pokémon Mystery Dungeon: Explorers of Time", link = "w:c:pokemon:Pokémon Mystery Dungeon: Explorers of Time & Explorers of Darkness", release = nil, mediatype = type.CHIPTUNE },

["pkmn_rse"] = { name = "Pokémon Ruby / Sapphire / Emerald", link = "w:c:pokemon:Pokémon Ruby and Sapphire Version", release = nil, mediatype = type.CHIPTUNE },

["advancewars2"] = { name = "Advance Wars 2: Black Hole Rising", link = "w:c:advancewars:Advance Wars 2: Black Hole Rising", release = nil, mediatype = type.CHIPTUNE },

["ghosttrick"] = { name = "Ghost Trick: Phantom Detective", link = "w:c:ghosttrick:Ghost Trick Original Sound Track", release = "2010", mediatype = type.CHIPTUNE },

["dronpa"] = { name = "Danganronpa: Trigger Happy Havoc", link = "w:c:danganronpa:Danganronpa: Trigger Happy Havoc (Original Soundtrack)", release = nil, mediatype = type.GAME_OST },

["chronocross"] = { name = "Chrono Cross", link = nil, release = nil, mediatype = type.CHIPTUNE },   ["daigyakuten"] = { name = "Dai Gyakuten Saiban: Naruhodō Ryūnosuke no Bōken", link = "w:c:aceattorney:Dai Gyakuten Saiban", release = "2015", mediatype = type.GAME_OST },

["daigyakuten2"] = { name = "Dai Gyakuten Saiban 2: Naruhodō Ryūnosuke no Kakugo", link = "w:c:aceattorney:Dai Gyakuten Saiban 2: Naruhodō Ryūnosuke no Kakugo", release = "2017", mediatype = type.GAME_OST },

["traumacenterwii"] = { name = "Trauma Center: Second Opinion", link = nil, release = nil, mediatype = type.GAME_OST },   ["traumacenter"] = { name = "Trauma Center: Under the Knife", link = nil, release = nil, mediatype = type.CHIPTUNE },

["traumacenter2"] = { name = "Trauma Center: Under the Knife 2", link = nil, release = nil, mediatype = type.CHIPTUNE },

["traumateam"] = { name = "Trauma Team", link = nil, release = nil, mediatype = type.GAME_OST },

["traumacenternb"] = { name = "Trauma Center: New Blood", link = nil, release = nil, mediatype = type.GAME_OST },

["fireemblemawake"] = { name = "Fire Emblem: Awakening", link = nil, release = nil, mediatype = type.GAME_OST },

["fireemblemfates"] = { name = "Fire Emblem Fates", link = nil, release = nil, mediatype = type.GAME_OST },

["smash4"] = { name = "Super Smash Bros. for Wii U", link = nil, release = nil, mediatype = type.GAME_OST },

["icarusuprising"] = { name = "Kid Icarus: Uprising", link = nil, release = nil, mediatype = type.GAME_OST },

["pkmndp"] = { name = "Pokémon Diamond / Pearl", link = nil, release = nil, mediatype = type.CHIPTUNE },

["pbr"] = { name = "Pokémon Battle Revolution", link = nil, release = nil, mediatype = type.GAME_OST },

["pkmnhgss"] = { name = "Pokémon Heartgold / Soulsilver", link = nil, release = nil, mediatype = type.CHIPTUNE },

["pkmnbw"] = { name = "Pokémon Black / White", link = nil, release = nil, mediatype = type.CHIPTUNE },

["pllastspecter"] = { name = "Professor Layton and the Last Specter", link = nil, release = nil, mediatype = type.CHIPTUNE },

["pwaasoj"] = { name = "Phoenix Wright: Ace Attorney ~ Spirit of Justice", link = nil, release = nil, mediatype = type.GAME_OST } } setmetatable(source, {   __index = function(t, i)        return { name = "( Undefined )", mediatype = -1 }    end })

local songs = { [source.plvpwaa] = { {"h3Ysg4Tlu-4", "Puzzle Deductions"}, {"R7czv7Ij3iM",  "Trial of the Great Witch"} },   [source.sonicmania] = { {"WxIElxztRk", "Flying Battery Zone, Act 1"}, {"YJG5FZDun9I", "Hydrocity Zone, Act 2"} },   [source.pmd_eot] = { {"ZEL3__eZIuA", "Temporal Tower"} },   [source.pkmn_rse] = { {"7vif4oZGnH0", "Mt. Pyre Outer Wall"} },

[source.advancewars2] = { {"EPjkLIcyEcc", "Black Hole Super CO Power"}, {"JsEnlbZunzE", "Sturm's Theme"} },   [source.ghosttrick] = { {"wwC2PVgufLk", "A Dashing Enigma"}, {"ywz-aGga0qU", "AWAKENING"}, {"8W8xu_pxgP0", "CHASE"}, {"8lO1GurMClg", "Dead Afterimage"}, {"ZcG5OeQg9S0", "Jowd ~ A Captive of Fate"}, {"p63H1Gy4-DM", "The Imprisoned"}, {"VHLKzQB7irk", "TRAUMA"}, {"mT9vFqZHGD4", "Unused Track #5"}, },   [source.dronpa] = { {"xOpHT6gZ0Rs", "BOX 15"}, {"rKVty1HGvx8", "Weekly Despair Magazine"}, {"xKSRb0y6Lb8", "Class Trial Solar Edition"}, {"m3EHCTP3jic", "New World Order"}, },   [source.chronocross] = { {"H-IJV93FQZc", "Dragon God"}, },   [source.daigyakuten] = { {"JUVlITp3qj0", "Pursuit ~ Time for a Great Turnabout"}, {"VSg-arCwnGQ", "Naruhodou Ryuunosuke ~ Objection!"} },

[source.daigyakuten2] = { {"OWiejCtmgmM", "Pursuit ~ The Great Turnabout 2017"} },   [source.traumacenterwii] = { {"okxgCNFav30", "Second Opinion"}, {"qr2R387hyHI", "St. Francis Hospital"}, {"fimZIwYgKzQ", "A Savior's Forthcoming"}, {"11cvXLY7vOE", "Vulnerability"} },

[source.traumacenter] = { {"ULKvwNBvD4w", "System: Opening"}, {"tS1vYQrPl9s", "Large Map 2 - Last Half"}, {"0N2bmR_YGyo", "Ending"} },

[source.traumacenter2] = { {"qCAu8Zm-ZV8", "Gentle Breeze"}, {"sVHSntwaDIM", "Doctors on Duty"}, {"fC0jbgNdea4", "Darkness Sets In"}, {"pcYEEhqgdVs", "Unfaltering Hands"}, {"JtbFa0Gb3gs", "Confronting the Menace"}, {"0M0IRuLiqYA", "Severing the Chains of Fate"}, },

[source.traumateam] = { {"FsrcD74oz5M", "Bloody Rose"} },

[source.traumacenternb] = { {"OLJucAGWT-A", "Pleasant Day"}, {"ZynYKnrOqh8", "Warning"}, {"bC0acSL_U88", "Bad News"}, {"8RMT2IUXt6A", "Life at Stakes"}, {"PcGjQQg5ZhM", "Miracle Surgery!"}, --     {"3xCyEE-Nvg0", "Awakening"} },

[source.fireemblemawake] = { {"yc1v-lGWkMc", "Id ~ Return/Id ~ Purpose Medley"}, {"EpflXpqk4CA", "Conquest (Ablaze)"} },

[source.fireemblemfates] = { {"KA6IVBtUx1w", "Alight"}, {"eqvM63tUz2Q", "Alight (Storm)"}, {"U_3M6CAPiJU", "Alight (Storm)", mediatype = type.REMIX} },   [source.smash4] = { {"L2jMZFdcETY", "Lost in Thoughts All Alone"} -- From Fire Emblem Fates },

[source.icarusuprising] = { {"RH_adANFSl8", "Chapter 15: Aurum Island"} },

[source.touhou] = { --     {"3kUWXTvfEdI", "Heian Alien", mediatype = type.REMIX} },   [source.ttr] = { --     {"8izb_1hB_yA", "Doomsday"} },

[source.pwaa] = { --     {"Q1xoRi7Mf5I", "Turnabout Sisters", mediatype = type.REMIX} },

[source.pkmndp] = { {"T8cLW0Lckhc", "Route 216 (Daytime)"}, {"XqBaDX33Eew", "Mt. Coronet"}, {"xr9KFynxBpA", "Eterna Forest"}, -- If only for that lick at 0:40 and 0:57 ...and 1:04 {"DYaYEEWkthI", "Route 228 (Daytime)"} },   [source.pkmnbw] = { {"CV_2u6EDx6c", "Route 10"} -- The only song I know from the gen.   },

[source.pkmnhgss] = { {"cJZnt1YEUFQ", "Game Corner"}, {"O2Hs4s9LLVg", "Battle! Ho-Oh"} },

[source.pwaasoj] = { {"bu55SrCtC-o", "Investigation ~ Core 2016"} },

[source.pbr] = { {"cpoX8IduLo4", "Beta Track"}, {"pRXug_r_XRA", "Colosseum Leader - Joe's Theme"}, {"jW9A35Lqcy8", "Courtyard Colosseum"}, {"1irHwwUQNZM", "Crystal Colosseum"}, {"YzqyTvh5PAw", "Final Battle Theme - Mysterial's Theme"}, {"xM1b8wGJ-Ww", "Lagoon Colosseum"}, {"sIb5v2XfHeU", "Main Menu - Game Mode Menu"}, {"SwlzjsrCz0Y", "Stargazer Colosseum"}, {"9WdxbMxb8zA", "Pokémon Wheel"}, {"FYi219M3CJg", "Sunny Park Colosseum"}, {"JXbSFgZdCKA", "Waterfall Colosseum"}, },

[source.pllastspecter] = { {"EK-NG-eDp7Q", "Puzzles (Live Version)", mediatype = type.REMIX} } }

local make = { table = function(str, frame) return frame:preprocess("{| class=articletable \n" .. str .. "\n|}") end, row = function(str, title) return (title and "!" or "|") .. str .. "\n|-\n" end, link = function(str, link, out) return link and (               out and ("[" .. link .. " " .. str .. "]")               or ("" .. str .. "")            ) or str end }

return { main = function(frame) local ostOrder = {} local nSongs = 0 -- Gather collection info for ost,soundtracks in pairs(songs) do           local n = #soundtracks nSongs = nSongs + n           table.insert(ostOrder, ost) end mw.log("Number of songs: " .. tostring(nSongs)) -- Choose song & find math.randomseed(os.time) local rIndex, sum, currOst = math.random(1, nSongs), 0 for i = 1, #ostOrder do           currOst = ostOrder[i] local newSum = sum + #songs[currOst] if newSum >= rIndex then break end sum = newSum end -- Generate song widget local selectedSong = songs[currOst][rIndex -sum] local songWidget, footer = " " .. selectedSong[1] .. " ",           " • [ (new song)]" return frame and make.table(           make.row('"' .. selectedSong[2] .. '"' .. ((selectedSong.mediatype or currOst.mediatype) > 1 and " (REMIX)" or ), true) ..           make.row("" .. make.link(               currOst.name .. (currOst.release and (' (' .. currOst.release .. ')') or ""),               currOst.link) .. "''") ..           make.row(songWidget .. make.link("(song src)",                   "https://youtu.be/" .. selectedSong[1],                    true                ) .. footer )      , frame) end,

list = function end }