Skip to content

Commit

Permalink
Added RadioU, Los40, GensokyoRadio scrapers
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnici committed Sep 4, 2016
1 parent 8e57c4f commit 217eedd
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 3 deletions.
8 changes: 7 additions & 1 deletion main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion main.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import gnl = require("./scrapers/cheerio/GnlScraper");
//import raveo = require("./scrapers/cheerio/RaveoScraper");
import belly = require("./scrapers/cheerio/BellyUp4BluesScraper");
import nexus = require("./scrapers/cheerio/NexusScraper");
import gensokyo = require("./scrapers/cheerio/GensokyoRadioScraper");

import amazing = require("./scrapers/json/AmazingRadioScraper");
import chronisch = require("./scrapers/json/ChronischScraper");
Expand Down Expand Up @@ -92,6 +93,8 @@ import cpr = require("./scrapers/json/CprScraper");
import radioRiel = require("./scrapers/json/RadioRielScraper");
import radioNova = require("./scrapers/json/RadioNovaScraper");
import megaStarFm = require("./scrapers/json/MegaStarFmScraper");
import radioU = require("./scrapers/json/RadioUScraper");
import los40 = require("./scrapers/json/Los40Scraper");

// Required environment variables
var STATION_CRYPTO_KEY = process.env.SA_STATION_CRYPTO_KEY;
Expand Down Expand Up @@ -224,7 +227,10 @@ var scrapers:{ [index: string]: scrap.Scraper; } = {
RadioRiel: new radioRiel.RadioRielScraper("RadioRiel"),
RadioNova: new radioNova.RadioNovaScraper("RadioNova"),
MegaStarFm: new megaStarFm.MegaStarFmScraper("MegaStarFM"),
Nexus: new nexus.NexusScraper("Nexus")
Nexus: new nexus.NexusScraper("Nexus"),
RadioU: new radioU.RadioUScraper("RadioU"),
Gensokyo: new gensokyo.GensokyoRadioScraper("Gensokyo"),
Los40: new los40.Los40Scraper("Los40")
};

var lastfmNode = new lastfm.LastFmNode({
Expand Down
32 changes: 32 additions & 0 deletions scrapers/cheerio/GensokyoRadioScraper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scrapers/cheerio/GensokyoRadioScraper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions scrapers/cheerio/GensokyoRadioScraper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference path="../../definitions/typescript-node-definitions/winston.d.ts"/>

import scrap = require("./CheerioScraper");
import song = require("../../Song");

import winston = require("winston");

export class GensokyoRadioScraper extends scrap.CheerioScraper {

constructor(name:string) {
super(name);
this.xmlMode = true;
}

getUrl(scraperParam?:string): string {
return "https://gensokyoradio.net/xml/";
}

public parseCheerio($:any, callback:(err, newNowPlayingSong:song.Song, justScrobbledSong?:song.Song) => void):void {
var titleElem = $('GENSOKYORADIODATA SONGINFO TITLE');
var artistElem = $('GENSOKYORADIODATA SONGINFO ARTIST');

if (titleElem.length < 1 || artistElem.length < 1) {
callback(null, { Artist: null, Track: null }, null);
return;
}


var track = titleElem.eq(0).text().trim();
var artist = artistElem.eq(0).text().trim();

callback(null, { Artist: artist, Track: track }, null);
}
}
23 changes: 23 additions & 0 deletions scrapers/json/Los40Scraper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scrapers/json/Los40Scraper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions scrapers/json/Los40Scraper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference path="../../definitions/typescript-node-definitions/winston.d.ts"/>

import song = require("../../Song");
import jsonScrap = require("./JsonScraper");

import winston = require("winston");

export class Los40Scraper extends jsonScrap.JsonScraper {

constructor(name:string) {
super(name);
}

getUrl(): string {
return "http://www.yes.fm/a/radio/fm/hasonado/LOS40";
}

extractNowPlayingSong(jsonData:any): song.Song {
return { Artist: jsonData.result[0].artist, Track: jsonData.result[0].track };
}
}
26 changes: 26 additions & 0 deletions scrapers/json/RadioUScraper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scrapers/json/RadioUScraper.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions scrapers/json/RadioUScraper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// <reference path="../../definitions/typescript-node-definitions/winston.d.ts"/>

import song = require("../../Song");
import jsonScrap = require("./JsonScraper");

import winston = require("winston");

export class RadioUScraper extends jsonScrap.JsonScraper {

constructor(name:string) {
super(name);
}

getUrl(): string {
return "http://cc.net2streams.com/external/rpc.php?m=streaminfo.get&username=live&rid=live&_=" + new Date().getTime();
}

extractNowPlayingSong(jsonData:any): song.Song {
if (jsonData.data[0].track.artist === "Unknown") {
return { Artist: null, Track: null };
}
return { Artist: jsonData.data[0].track.artist, Track: jsonData.data[0].track.title };
}
}

0 comments on commit 217eedd

Please sign in to comment.