Adapter Score scraper for Score Videos.
This commit is contained in:
@@ -35,6 +35,19 @@ function qall(context, selector, attrArg, trim = true) {
|
||||
return Array.from(context.querySelectorAll(selector));
|
||||
}
|
||||
|
||||
function qtext(context, selector, trim = true) {
|
||||
const el = q(context, selector, false, trim);
|
||||
if (!el) return null;
|
||||
|
||||
const text = Array.from(el.childNodes)
|
||||
.filter(node => node.nodeName === '#text')
|
||||
.map(node => (trim ? node.textContent : node.textContent.trim()))
|
||||
.join(' ');
|
||||
|
||||
if (trim) return text.trim();
|
||||
return text;
|
||||
}
|
||||
|
||||
function qmeta(context, selector, attrArg = 'content', trim = true) {
|
||||
return q(context, selector, attrArg, trim);
|
||||
}
|
||||
@@ -95,6 +108,8 @@ function qtrailer(context, selector = 'source', attr = 'src', protocol = 'https'
|
||||
|
||||
function qlength(context, selector, attr = 'textContent') {
|
||||
const durationString = q(context, selector, attr);
|
||||
|
||||
if (!durationString) return null;
|
||||
const duration = durationString.match(/(\d+:)?\d+:\d+/);
|
||||
|
||||
if (duration) {
|
||||
@@ -115,6 +130,7 @@ const funcs = {
|
||||
qposter,
|
||||
qlength,
|
||||
qmeta,
|
||||
qtext,
|
||||
qtrailer,
|
||||
qurls,
|
||||
qurl,
|
||||
@@ -126,6 +142,7 @@ const funcs = {
|
||||
ql: qlength,
|
||||
qm: qmeta,
|
||||
qt: qtrailer,
|
||||
qtx: qtext,
|
||||
qu: qurl,
|
||||
qus: qurls,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user