Commit 3800c2a0 authored by yPhil's avatar yPhil
Browse files

MediaRSS: Video player OK, Audio tomorrow

parent 0f3304c1
Pipeline #399277 failed with stage
in 1 minute and 34 seconds
......@@ -22,6 +22,7 @@ app.disable('x-powered-by');
app.use(compression());
app.use(helmet.originAgentCluster());
app.use(helmet.noSniff());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
......
......@@ -316,6 +316,8 @@ PTL.feed = {
var $description = $.parseHTML(item.description),
summary,
imageUrl,
videoUrl,
videoType,
imageUrls = [],
imgTypes = ['image',
'image/jpg',
......@@ -396,6 +398,19 @@ PTL.feed = {
}
}
if (item['media:group']) {
if (item['media:group']['media:content']) {
if (item['media:group']['media:content'][0]) {
if (item['media:group']['media:content'][0]['@']) {
if (item['media:group']['media:content'][0]['@'].medium && item['media:group']['media:content'][0]['@'].medium === 'video') {
videoUrl = item['media:group']['media:content'][0]['@'].url;
videoType = item['media:group']['media:content'][0]['@'].type;
}
}
}
}
}
if (item.enclosures && typeof item.enclosures[0] !== 'undefined' && item.enclosures[0].url) {
if (item.enclosures[0].url && item.enclosures[0].url.endsWith(".jpg")) {
......@@ -406,12 +421,17 @@ PTL.feed = {
imageUrl = item.enclosures[0].url;
}
if (item.enclosures[0].url && item.enclosures[0].url.match(/\.(mp4|webm)$/)) {
if (!videoUrl && item.enclosures[0].url && item.enclosures[0].url.match(/\.(mp4|webm)$/)) {
videoUrl = item.enclosures[0].url;
videoType = item.enclosures[0].type;
}
if (videoUrl && videoType) {
var videoPlayer = document.createElement('video');
videoPlayer.controls = 'controls';
videoPlayer.src = item.enclosures[0].url;
videoPlayer.type = item.enclosures[0].type;
videoPlayer.src = videoUrl;
videoPlayer.type = videoType;
$itemDiv.append(videoPlayer);
......@@ -442,42 +462,20 @@ PTL.feed = {
}
}
if (item['media:group']) {
var mgmc = item['media:group']['media:content'];
for (var i = 0; i < mgmc.length; i++) {
if (mgmc[i]['@'].url) imageUrl = mgmc[i]['@'].url;
}
}
// if (item['media:group']) {
// var mgmc = item['media:group']['media:content'];
// for (var i = 0; i < mgmc.length; i++) {
// if (mgmc[i]['@'].url) imageUrl = mgmc[i]['@'].url;
// }
// }
$itemLink
.attr('class', 'ui-helper-clearfix feed-link')
.attr('href', item.link || item.enclosures[0].url)
.append(item['mastodon:scope'] ? $summary.trim() : item.title);
if (imageUrls && imageUrls.length >= 1) {
console.log('imageUrls.length: %s (%s)',imageUrls.length);
$image = $('<div>')
.attr('class', 'ptl-img')
.appendTo($imageLink);
for (var i = 0, len = imageUrls.length; i < len; i++) {
$('<a>')
.attr('href', imageUrls[i])
.attr('data-fancybox', 'gallery')
// .attr('data-caption', $imageLinkButton)
.appendTo($image)
.append($('<img>')
.attr('src', imageUrls[i])
.attr('alt', item['mastodon:scope'] ? $summary.trim() : item.title)
.appendTo($image));
}
} else if (imageUrl && typeof imageUrl !== 'undefined' && !imageUrl.includes('pixel')) {
if (!videoUrl && imageUrl && typeof imageUrl !== 'undefined' && !imageUrl.includes('pixel')) {
// Can't pass a JQ object as the button
$imageLink
.attr('href', imageUrl)
.attr('title', $summary.trim())
......
......@@ -320,7 +320,7 @@ var PTL = (function() {
$.fancybox.defaults.buttons = [
'slideShow',
'fullScreen',
'thumbs',
// 'thumbs',
'download',
'zoom',
'close'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment