Continued work on media scheduler
This commit is contained in:
parent
9d01b4c962
commit
d5a2a51be2
14 changed files with 415 additions and 54 deletions
|
|
@ -21,7 +21,7 @@ const validator = require('validator');//No express here, so regular validator i
|
|||
const iaUtil = require('./internetArchiveUtils');
|
||||
const media = require('../../app/channel/media/media');
|
||||
|
||||
module.exports.yankMedia = async function(url){
|
||||
module.exports.yankMedia = async function(url, title){
|
||||
const pullType = await this.getMediaType(url);
|
||||
|
||||
if(pullType == 'ia'){
|
||||
|
|
@ -34,13 +34,21 @@ module.exports.yankMedia = async function(url){
|
|||
for(let file of mediaInfo.files){
|
||||
//Split file path by directories
|
||||
const path = file.name.split('/');
|
||||
|
||||
//pull filename from path
|
||||
const name = path[path.length - 1];
|
||||
|
||||
//Construct link from pulled info
|
||||
const link = `https://archive.org/download/${mediaInfo.metadata.identifier}/${file.name}`;
|
||||
|
||||
//Create new media object from file info
|
||||
mediaList.push(new media(name, name, link, link, 'ia', Number(file.length)));
|
||||
//if we where handed a null title
|
||||
if(title == null || title == ''){
|
||||
//Create new media object from file info substituting filename for title
|
||||
mediaList.push(new media(name, name, link, link, 'ia', Number(file.length)));
|
||||
}else{
|
||||
//Create new media object from file info
|
||||
mediaList.push(new media(title, name, link, link, 'ia', Number(file.length)));
|
||||
}
|
||||
}
|
||||
|
||||
//return media object list
|
||||
|
|
@ -52,12 +60,16 @@ module.exports.yankMedia = async function(url){
|
|||
}
|
||||
|
||||
module.exports.getMediaType = async function(url){
|
||||
//Encode URI in-case we where handed something a little too humie friendly
|
||||
url = encodeURI(url);
|
||||
|
||||
//Check if we have a valid url
|
||||
if(!validator.isURL(url)){
|
||||
//If not toss the fucker out
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//If we have link to a resource from archive.org
|
||||
if(url.match(/^https\:\/\/archive.org\//g)){
|
||||
//return internet archive code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue