-
Notifications
You must be signed in to change notification settings - Fork 1
/
libgetmetadata.js
36 lines (30 loc) · 1.02 KB
/
libgetmetadata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// libgetmetadata - Collect metadata for creative works from various sources.
//
// Copyright 2014 Commons Machinery http://commonsmachinery.se/
//
// Distributed under an GPLv2 license, please see LICENSE in the top dir.
'use strict';
var devart = require('./lib/devart.js');
var flickr = require('./lib/flickr.js');
var discover = require('./lib/discover.js');
var notImplemented = {
getMedia: function(url) {
throw new Error("Couldn't find metadata module for site " + url);
}
};
var siteModules = {
'^https?:\/\/[a-zA-Z0-9][a-zA-Z0-9-]*\.deviantart\.com\/art\/.*': devart,
'^https?:\/\/fav.me\/.*': devart,
'^https?:\/\/sta.sh/.*': devart,
'^https?:\/\/[a-zA-Z0-9][a-zA-Z0-9-]*\.deviantart\.com\/.*?#\/d.*': devart,
'^https?:\/\/(www\\.)?flickr\\.com/photos/': flickr,
'.*': discover,
};
var getMetadata = function(url) {
for (var k in siteModules) {
if (url.match(new RegExp(k))) {
return siteModules[k].getMedia(url);
}
}
};
module.exports = getMetadata;