forked from jonsmy/glowers-radio
		
	generate.js: negromancy
This commit is contained in:
		
							
								
								
									
										55
									
								
								generate.js
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								generate.js
									
									
									
									
									
								
							| @@ -11,6 +11,14 @@ const objSerialize = (obj, keys, cb) => { | |||||||
|     return a |     return a | ||||||
| } | } | ||||||
|  |  | ||||||
|  | const objBulkSet = (obj, target, pairs) => { | ||||||
|  |     if (typeof obj[target] != "object") | ||||||
|  |         obj[target] = Object.create(null) | ||||||
|  |     for (const key in pairs) | ||||||
|  |         if (pairs[key] != undefined) | ||||||
|  |             obj[target][key] = pairs[key] | ||||||
|  | } | ||||||
|  |  | ||||||
| const RadioItem = function (id) { | const RadioItem = function (id) { | ||||||
|     this.id = id |     this.id = id | ||||||
|     this.metadata = undefined |     this.metadata = undefined | ||||||
| @@ -20,9 +28,19 @@ const RadioItem = function (id) { | |||||||
| } | } | ||||||
|  |  | ||||||
| RadioItem.new = id => new RadioItem(id) | RadioItem.new = id => new RadioItem(id) | ||||||
| RadioItem.prototype.setMetadata = function (title, artist) { this.metadata = { title, artist }; return this } | RadioItem.prototype.setMetadata = function (title, artist, href) { objBulkSet(this, "metadata", { title, artist, href }); return this } | ||||||
|  | RadioItem.prototype.addTags = function (tags) { this.tags = this.tags ? [ ...(this.tags), ...tags ] : tags; return this } | ||||||
| RadioItem.prototype.setTags = function (tags) { this.tags = tags; return this } | RadioItem.prototype.setTags = function (tags) { this.tags = tags; return this } | ||||||
| RadioItem.prototype.addSource = function (source) { this.sources.push(source); return this } | RadioItem.prototype.addSource = function (source) { this.sources.push(source); return this } | ||||||
|  | RadioItem.prototype.setNiggadata = function (nigid, nigkey) { | ||||||
|  |     this.setMetadata() | ||||||
|  |     this.metadata._nigid = nigid | ||||||
|  |     this.metadata._nigkey = nigkey | ||||||
|  |     this.addTags([ "niggers" ]) | ||||||
|  |     //.setThumbnailType(EThumbnailType.STRETCH)) | ||||||
|  |     return this | ||||||
|  | } | ||||||
|  |  | ||||||
| RadioItem.prototype.serialize = function () { | RadioItem.prototype.serialize = function () { | ||||||
|     return objSerialize(this, [ |     return objSerialize(this, [ | ||||||
|         "id", |         "id", | ||||||
| @@ -245,7 +263,38 @@ const radioEntries = [ | |||||||
|         .setURL("mxc://glowers.club/egmaXMIHsNmblfDjyTGHdyas") |         .setURL("mxc://glowers.club/egmaXMIHsNmblfDjyTGHdyas") | ||||||
|         .setThumbnailURL("mxc://glowers.club/wpwHKoSFsxkNttaNyaNFzhMk")), |         .setThumbnailURL("mxc://glowers.club/wpwHKoSFsxkNttaNyaNFzhMk")), | ||||||
|  |  | ||||||
|  |     RadioItem.new("hatethem") | ||||||
|  |       .setMetadata("Niggerz Bop", "Mike David", "https://youtu.be/VkcAXS9IKdc") | ||||||
|  |       .setNiggadata("hatethem", "585a286c042231244a73b19e") | ||||||
|  |       .addSource(RadioSource.new("audio/ogg") | ||||||
|  |         .setURL("mxc://glowers.club/wdflEjUfqAkoyOyCDBXebDkw") | ||||||
|  |         .setThumbnailURL("mxc://glowers.club/IbShqtSWZksFbnOdFiVDFwqD")), | ||||||
|  |  | ||||||
|  |     RadioItem.new("wishmaster") | ||||||
|  |       .setMetadata("Wishmaster", "Van Canto", "https://youtu.be/XCGQiGEYl4Y") | ||||||
|  |       .setNiggadata("wishmaster", "570550d318f3c6dc5677b9f6") | ||||||
|  |       .addSource(RadioSource.new("audio/ogg") | ||||||
|  |         .setURL("mxc://glowers.club/uaxDKxCUtRVXMWAJgoKeiNcJ") | ||||||
|  |         .setThumbnailURL("mxc://glowers.club/OKTbfAlagYXulaeBmgwkNwii") | ||||||
|  |         .setThumbnailType(EThumbnailType.STRETCH)), | ||||||
|  |  | ||||||
|  |     RadioItem.new("negromancy") | ||||||
|  |       .setMetadata(undefined, undefined, "https://youtu.be/PxjA-jq1e7E") | ||||||
|  |       .setTags([ "misc" ]) | ||||||
|  |       .addSource(RadioSource.new("video/webm") | ||||||
|  |         .setURL("mxc://glowers.club/hRDjowdyaPRkdrRkHtCeqGug") | ||||||
|  |         .setThumbnailURL("mxc://glowers.club/qAtvGoVERlYfFnNWeizoYiGP")), | ||||||
|  |  | ||||||
| ].filter(Boolean).map(a => a.serialize()).sort((a,b) => a.id.localeCompare(b.id)) | ].filter(Boolean).map(a => a.serialize()).sort((a,b) => a.id.localeCompare(b.id)) | ||||||
|  |  | ||||||
| fs.writeFileSync("./data/songs.js", `glowersRadioSongsCallback(${JSON.stringify(radioEntries)})`) | const radioObj = { | ||||||
| fs.writeFileSync("./data/songs.json", JSON.stringify(radioEntries)) |     "version": 2, | ||||||
|  |     "songs": radioEntries | ||||||
|  | } | ||||||
|  |  | ||||||
|  | fs.writeFileSync("./data/songs.json", JSON.stringify(radioObj)) | ||||||
|  | //fs.writeFileSync("./data/songs.js", `glowersRadioSongsCallback(${JSON.stringify(radioObj)})`) | ||||||
|  | //fs.writeFileSync("./data/songs.html", `<html><script>glowersRadioSongsCallback(${JSON.stringify(radioObj)})</script></html>`) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user