Major refactor of service libs, more tests
This commit is contained in:
parent
cda69ea472
commit
ce3ff0442c
19 changed files with 288 additions and 118 deletions
30
lib/services/google/url.js
Normal file
30
lib/services/google/url.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
var parse = require('url').parse;
|
||||
|
||||
module.exports.match = function(url) {
|
||||
var parsed = parse(url.replace(/\+/g, "%20"));
|
||||
if (!parsed.host.match(/play\.google\.com$/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var path = parsed.path;
|
||||
var hash = parsed.hash;
|
||||
|
||||
if (hash) {
|
||||
var parts = hash.split("/");
|
||||
var id = parts[2];
|
||||
var artist = parts[3];
|
||||
|
||||
if (id.length > 0) {
|
||||
return true;
|
||||
} else if (artist.length > 0) {
|
||||
return true;
|
||||
}
|
||||
} else if(path) {
|
||||
var matches = path.match(/\/music\/m\/([\w]+)/);
|
||||
if (matches[1]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue