Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Promise.reject(err)
}
// new song
const { artist, title } = parseMeta(item.snippet.title, parseMetaCfg)
if (!artist || !title) {
log(' => skipping: couldn\'t parse artist/title from video title')
return Promise.reject(new Error('couldn\'t parse artist/title'))
}
const song = {
artist,
title,
provider: 'youtube',
duration: toSeconds(parse(item.contentDetails.duration)),
providerData: {
videoId: item.id,
channel: item.channel,
publishedAt: item.snippet.publishedAt,
}
}
try {
const mediaId = await Media.add(song)
return Promise.resolve(mediaId)
} catch (err) {
return Promise.reject(err)
}
}
export async function lookupId(id) {
const path = `/videos?part=snippet%2CcontentDetails&id=${id}&key=${credentials.key}`;
try {
const result = await request.get(apiRoot + path);
const item = result.body.items[0].snippet;
const duration = toSeconds(ptParse(result.body.items[0].contentDetails.duration));
const split = item.title.match(/([^-]+)-(.*)/);
const artist = split[1].trim();
const name = split[2].match(/^[^([]+/)[0].trim();
// nodebrainz.luceneSearch('recording', {artist, query: release }, (err, response) => {
// const recording = response.recordings[0];
// debug(recording.releases[0].media[0].track[0].title)
// artist = recording['artist-credit'].name;
// release = recording.media;
// });
const match = {
id,
type: 'album',
function resolveDuration() {
const isoDuration = executionContext.resolveExpression(duration);
return iso8601duration.toSeconds(iso8601duration.parse(isoDuration)) * 1000;
}
function executeTimer() {
const isoDuration = timeDuration && environment.resolveExpression(timeDuration, startMessage);
const timeout = isoDuration ? toSeconds(parse(isoDuration)) * 1000 : 0;
const startedAt = new Date();
debug(`<${executionId} (${id})> start timer ${timeout}ms, duration ${isoDuration || 'none'}`);
timerContent = {...messageContent, isoDuration, timeout, startedAt, state: 'timer'};
broker.publish('execution', 'execute.timer', cloneContent(timerContent));
broker.publish('event', 'activity.timer', cloneContent(timerContent));
timer = setTimeout(completed, timeout);
}
const formatDuration = (duration) => {
let seconds = toSeconds(parse(duration));
const hours = Math.floor(seconds / 60 / 60);
seconds -= hours * 60 * 60;
const minutes = Math.floor(seconds / 60);
seconds -= minutes * 60;
const parts = [
hours,
minutes,
seconds
];
if (parts[0] === 0) {
parts.shift();
}
const intervalParser = (value) => {
return value === null ? value : durationToSeconds(parseIsoDuration(parseInterval(value).toISOString()));
};
noscript.each(function(idx: number, elem: any) {
const node = ctx.state.$!(elem)
const text = node.text()
if (text.indexOf('schema.org') === -1) {
return
}
const $ = load(text)
const metaDuration = $(`meta[itemprop='duration']`).attr('content')
if (metaDuration) {
const duration = toSeconds(parse(metaDuration)) * 1000
if (duration && !isNaN(duration)) {
ctx.res.duration = duration
}
}
})
}