2016-09-14 23:23:39 -07:00
|
|
|
define(['datetime', 'globalize', 'embyRouter', 'itemHelper', 'material-icons', 'css!./mediainfo.css', 'programStyles'], function (datetime, globalize, embyRouter, itemHelper) {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
2016-10-03 22:15:39 -07:00
|
|
|
function getTimerIndicator(item) {
|
|
|
|
|
|
|
|
var status;
|
|
|
|
|
|
|
|
if (item.Type == 'SeriesTimer') {
|
|
|
|
return '<i class="md-icon mediaInfoItem mediaInfoIconItem mediaInfoTimerIcon"></i>';
|
|
|
|
}
|
2016-10-10 23:46:59 -07:00
|
|
|
else if (item.TimerId || item.SeriesTimerId) {
|
2016-10-03 22:15:39 -07:00
|
|
|
|
2016-10-10 23:46:59 -07:00
|
|
|
status = item.Status || 'Cancelled';
|
2016-10-03 22:15:39 -07:00
|
|
|
}
|
|
|
|
else if (item.Type == 'Timer') {
|
|
|
|
|
|
|
|
status = item.Status;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.SeriesTimerId) {
|
|
|
|
|
2016-10-08 21:58:57 -07:00
|
|
|
if (status != 'Cancelled') {
|
2016-10-03 22:15:39 -07:00
|
|
|
return '<i class="md-icon mediaInfoItem mediaInfoIconItem mediaInfoTimerIcon"></i>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<i class="md-icon mediaInfoItem mediaInfoIconItem"></i>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<i class="md-icon mediaInfoItem mediaInfoIconItem mediaInfoTimerIcon"></i>';
|
|
|
|
}
|
|
|
|
|
2016-05-11 15:08:19 -07:00
|
|
|
function getProgramInfoHtml(item, options) {
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
var miscInfo = [];
|
|
|
|
var text, date;
|
|
|
|
|
|
|
|
if (item.StartDate) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
date = datetime.parseISO8601Date(item.StartDate);
|
|
|
|
|
2016-09-15 23:32:40 -07:00
|
|
|
text = datetime.toLocaleDateString(date, { weekday: 'short', month: 'short', day: 'numeric' });
|
2016-05-11 15:08:19 -07:00
|
|
|
|
2016-09-14 09:20:03 -07:00
|
|
|
text += ' ' + datetime.getDisplayTime(date);
|
2016-05-11 15:08:19 -07:00
|
|
|
|
|
|
|
if (item.EndDate) {
|
|
|
|
date = datetime.parseISO8601Date(item.EndDate);
|
|
|
|
text += ' - ' + datetime.getDisplayTime(date);
|
|
|
|
}
|
|
|
|
|
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log("Error parsing date: " + item.PremiereDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.ChannelNumber) {
|
|
|
|
miscInfo.push('CH ' + item.ChannelNumber);
|
|
|
|
}
|
|
|
|
|
2016-09-14 09:20:03 -07:00
|
|
|
if (item.ChannelName) {
|
|
|
|
|
|
|
|
if (options.interactive && item.ChannelId) {
|
|
|
|
miscInfo.push('<a class="lnkChannel" data-id="' + item.ChannelId + '" data-serverid="' + item.ServerId + '" href="#">' + item.ChannelName + '</a>');
|
|
|
|
} else {
|
|
|
|
miscInfo.push(item.ChannelName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 09:51:16 -07:00
|
|
|
if (options.timerIndicator !== false) {
|
2016-10-03 22:15:39 -07:00
|
|
|
var timerHtml = getTimerIndicator(item);
|
|
|
|
if (timerHtml) {
|
2016-09-20 09:51:16 -07:00
|
|
|
miscInfo.push({
|
2016-10-03 22:15:39 -07:00
|
|
|
html: timerHtml
|
2016-09-20 09:51:16 -07:00
|
|
|
});
|
|
|
|
}
|
2016-05-11 22:58:05 -07:00
|
|
|
}
|
|
|
|
|
2016-05-11 15:08:19 -07:00
|
|
|
html += miscInfo.map(function (m) {
|
|
|
|
return getMediaInfoItem(m);
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMediaInfoHtml(item, options) {
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
var miscInfo = [];
|
|
|
|
options = options || {};
|
|
|
|
var text, date, minutes;
|
|
|
|
|
2016-05-13 21:48:59 -07:00
|
|
|
var showFolderRuntime = item.Type == "MusicAlbum" || item.MediaType == 'MusicArtist' || item.MediaType == 'Playlist' || item.MediaType == 'MusicGenre';
|
|
|
|
|
|
|
|
if (showFolderRuntime) {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
|
|
|
var count = item.SongCount || item.ChildCount;
|
|
|
|
|
|
|
|
if (count) {
|
|
|
|
|
2016-05-12 12:21:43 -07:00
|
|
|
miscInfo.push(globalize.translate('sharedcomponents#TrackCount', count));
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
|
2016-05-13 21:48:59 -07:00
|
|
|
if (item.RunTimeTicks) {
|
|
|
|
miscInfo.push(datetime.getDisplayRunningTime(item.RunTimeTicks));
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (item.Type == "PhotoAlbum" || item.Type == "BoxSet") {
|
|
|
|
|
|
|
|
var count = item.ChildCount;
|
|
|
|
|
|
|
|
if (count) {
|
|
|
|
|
2016-05-12 12:21:43 -07:00
|
|
|
miscInfo.push(globalize.translate('sharedcomponents#ItemCount', count));
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.Type == "Episode" || item.MediaType == 'Photo') {
|
|
|
|
|
|
|
|
if (item.PremiereDate) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
date = datetime.parseISO8601Date(item.PremiereDate);
|
|
|
|
|
2016-09-07 13:11:16 -07:00
|
|
|
text = datetime.toLocaleDateString(date);
|
2016-05-11 15:08:19 -07:00
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log("Error parsing date: " + item.PremiereDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.StartDate && item.Type != 'Program') {
|
|
|
|
|
|
|
|
try {
|
|
|
|
date = datetime.parseISO8601Date(item.StartDate);
|
|
|
|
|
2016-09-07 13:11:16 -07:00
|
|
|
text = datetime.toLocaleDateString(date);
|
2016-05-11 15:08:19 -07:00
|
|
|
miscInfo.push(text);
|
|
|
|
|
|
|
|
if (item.Type != "Recording") {
|
|
|
|
text = datetime.getDisplayTime(date);
|
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log("Error parsing date: " + item.PremiereDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-17 11:55:07 -07:00
|
|
|
if (options.year !== false && item.ProductionYear && item.Type == "Series") {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
|
|
|
if (item.Status == "Continuing") {
|
2016-05-12 12:21:43 -07:00
|
|
|
miscInfo.push(globalize.translate('sharedcomponents#ValueSeriesYearToPresent', item.ProductionYear));
|
2016-05-11 15:08:19 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (item.ProductionYear) {
|
|
|
|
|
|
|
|
text = item.ProductionYear;
|
|
|
|
|
|
|
|
if (item.EndDate) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
var endYear = datetime.parseISO8601Date(item.EndDate).getFullYear();
|
|
|
|
|
|
|
|
if (endYear != item.ProductionYear) {
|
|
|
|
text += "-" + datetime.parseISO8601Date(item.EndDate).getFullYear();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log("Error parsing date: " + item.EndDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.Type == 'Program') {
|
|
|
|
|
2016-05-11 22:58:05 -07:00
|
|
|
if (item.IsLive) {
|
|
|
|
miscInfo.push({
|
2016-09-14 23:23:39 -07:00
|
|
|
html: '<div class="mediaInfoProgramAttribute mediaInfoItem liveTvProgram">' + globalize.translate('sharedcomponents#Live') + '</div>'
|
2016-05-11 22:58:05 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (item.IsPremiere) {
|
|
|
|
miscInfo.push({
|
2016-09-14 23:23:39 -07:00
|
|
|
html: '<div class="mediaInfoProgramAttribute mediaInfoItem premiereTvProgram">' + globalize.translate('sharedcomponents#Premiere') + '</div>'
|
2016-05-11 22:58:05 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (item.IsSeries && !item.IsRepeat) {
|
|
|
|
miscInfo.push({
|
2016-09-14 23:23:39 -07:00
|
|
|
html: '<div class="mediaInfoProgramAttribute mediaInfoItem newTvProgram">' + globalize.translate('sharedcomponents#AttributeNew') + '</div>'
|
2016-05-11 22:58:05 -07:00
|
|
|
});
|
|
|
|
}
|
2016-08-29 21:33:24 -07:00
|
|
|
else if (item.IsSeries && item.IsRepeat) {
|
|
|
|
miscInfo.push({
|
2016-09-14 23:23:39 -07:00
|
|
|
html: '<div class="mediaInfoProgramAttribute mediaInfoItem repeatTvProgram">' + globalize.translate('sharedcomponents#Repeat') + '</div>'
|
2016-08-29 21:33:24 -07:00
|
|
|
});
|
|
|
|
}
|
2016-05-11 22:58:05 -07:00
|
|
|
|
2016-09-09 00:02:36 -07:00
|
|
|
if (item.IsSeries && item.EpisodeTitle && options.episodeTitle !== false) {
|
2016-09-07 13:11:16 -07:00
|
|
|
miscInfo.push(itemHelper.getDisplayName(item));
|
2016-08-29 21:33:24 -07:00
|
|
|
}
|
|
|
|
|
2016-09-27 10:51:01 -07:00
|
|
|
else if (item.PremiereDate && options.originalAirDate !== false) {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
|
|
|
try {
|
|
|
|
date = datetime.parseISO8601Date(item.PremiereDate);
|
2016-09-07 13:11:16 -07:00
|
|
|
text = globalize.translate('sharedcomponents#OriginalAirDateValue', datetime.toLocaleDateString(date));
|
2016-05-11 15:08:19 -07:00
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log("Error parsing date: " + item.PremiereDate);
|
|
|
|
}
|
|
|
|
} else if (item.ProductionYear) {
|
2016-05-12 12:21:43 -07:00
|
|
|
text = globalize.translate('sharedcomponents#ReleaseYearValue', item.ProductionYear);
|
2016-05-11 15:08:19 -07:00
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-03 22:15:39 -07:00
|
|
|
if (options.year !== false) {
|
|
|
|
if (item.Type != "Series" && item.Type != "Episode" && item.Type != "Person" && item.MediaType != 'Photo' && item.Type != 'Program') {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
2016-10-03 22:15:39 -07:00
|
|
|
if (item.ProductionYear) {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
2016-10-03 22:15:39 -07:00
|
|
|
miscInfo.push(item.ProductionYear);
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
2016-10-03 22:15:39 -07:00
|
|
|
else if (item.PremiereDate) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
text = datetime.parseISO8601Date(item.PremiereDate).getFullYear();
|
|
|
|
miscInfo.push(text);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log("Error parsing date: " + item.PremiereDate);
|
|
|
|
}
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-13 21:48:59 -07:00
|
|
|
if (item.RunTimeTicks && item.Type != "Series" && item.Type != 'Program' && !showFolderRuntime && options.runtime !== false) {
|
2016-05-11 15:08:19 -07:00
|
|
|
|
|
|
|
if (item.Type == "Audio") {
|
|
|
|
|
|
|
|
miscInfo.push(datetime.getDisplayRunningTime(item.RunTimeTicks));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
minutes = item.RunTimeTicks / 600000000;
|
|
|
|
|
|
|
|
minutes = minutes || 1;
|
|
|
|
|
|
|
|
miscInfo.push(Math.round(minutes) + " mins");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.OfficialRating && item.Type !== "Season" && item.Type !== "Episode") {
|
|
|
|
miscInfo.push({
|
|
|
|
text: item.OfficialRating,
|
|
|
|
cssClass: 'mediaInfoOfficialRating'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.Video3DFormat) {
|
|
|
|
miscInfo.push("3D");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.MediaType == 'Photo' && item.Width && item.Height) {
|
|
|
|
miscInfo.push(item.Width + "x" + item.Height);
|
|
|
|
}
|
|
|
|
|
2016-07-17 11:55:07 -07:00
|
|
|
if (options.container !== false && item.Type == 'Audio' && item.Container) {
|
2016-07-17 09:59:14 -07:00
|
|
|
miscInfo.push(item.Container);
|
|
|
|
}
|
|
|
|
|
2016-05-11 15:08:19 -07:00
|
|
|
html += miscInfo.map(function (m) {
|
|
|
|
return getMediaInfoItem(m);
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
html += getStarIconsHtml(item);
|
|
|
|
|
2016-05-11 22:58:05 -07:00
|
|
|
if (item.HasSubtitles && options.subtitles !== false) {
|
2016-08-01 22:55:52 -07:00
|
|
|
html += '<i class="md-icon mediaInfoItem closedCaptionIcon mediaInfoIconItem"></i>';
|
2016-05-11 22:58:05 -07:00
|
|
|
}
|
|
|
|
|
2016-05-11 15:08:19 -07:00
|
|
|
if (item.CriticRating && options.criticRating !== false) {
|
|
|
|
|
|
|
|
if (item.CriticRating >= 60) {
|
2016-08-01 22:55:52 -07:00
|
|
|
html += '<div class="mediaInfoItem mediaInfoCriticRating mediaInfoCriticRatingFresh">' + item.CriticRating + '</div>';
|
2016-05-11 15:08:19 -07:00
|
|
|
} else {
|
2016-08-01 22:55:52 -07:00
|
|
|
html += '<div class="mediaInfoItem mediaInfoCriticRating mediaInfoCriticRatingRotten">' + item.CriticRating + '</div>';
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.endsAt !== false) {
|
|
|
|
|
|
|
|
var endsAt = getEndsAt(item);
|
|
|
|
if (endsAt) {
|
|
|
|
html += getMediaInfoItem(endsAt, 'endsAt');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEndsAt(item) {
|
|
|
|
|
|
|
|
if (item.MediaType == 'Video' && item.RunTimeTicks) {
|
|
|
|
|
|
|
|
if (!item.StartDate) {
|
|
|
|
var endDate = new Date().getTime() + (item.RunTimeTicks / 10000);
|
|
|
|
endDate = new Date(endDate);
|
|
|
|
|
|
|
|
var displayTime = datetime.getDisplayTime(endDate);
|
2016-05-12 12:21:43 -07:00
|
|
|
return globalize.translate('sharedcomponents#EndsAtValue', displayTime);
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEndsAtFromPosition(runtimeTicks, positionTicks, includeText) {
|
|
|
|
|
|
|
|
var endDate = new Date().getTime() + ((runtimeTicks - (positionTicks || 0)) / 10000);
|
|
|
|
endDate = new Date(endDate);
|
|
|
|
|
|
|
|
var displayTime = datetime.getDisplayTime(endDate);
|
|
|
|
|
|
|
|
if (includeText === false) {
|
|
|
|
return displayTime;
|
|
|
|
}
|
2016-05-12 12:21:43 -07:00
|
|
|
return globalize.translate('sharedcomponents#EndsAtValue', displayTime);
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function getMediaInfoItem(m, cssClass) {
|
|
|
|
|
|
|
|
cssClass = cssClass ? (cssClass + ' mediaInfoItem') : 'mediaInfoItem';
|
|
|
|
var mediaInfoText = m;
|
|
|
|
|
|
|
|
if (typeof (m) !== 'string' && typeof (m) !== 'number') {
|
|
|
|
|
|
|
|
if (m.html) {
|
|
|
|
return m.html;
|
|
|
|
}
|
|
|
|
mediaInfoText = m.text;
|
|
|
|
cssClass += ' ' + m.cssClass;
|
|
|
|
}
|
|
|
|
return '<div class="' + cssClass + '">' + mediaInfoText + '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStarIconsHtml(item) {
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
var rating = item.CommunityRating;
|
|
|
|
|
|
|
|
if (rating) {
|
|
|
|
html += '<div class="starRatingContainer mediaInfoItem">';
|
|
|
|
|
2016-08-01 22:55:52 -07:00
|
|
|
html += '<i class="md-icon starIcon"></i>';
|
2016-05-11 22:58:05 -07:00
|
|
|
html += rating;
|
2016-05-11 15:08:19 -07:00
|
|
|
html += '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function dynamicEndTime(elem, item) {
|
|
|
|
|
|
|
|
var interval = setInterval(function () {
|
|
|
|
|
|
|
|
if (!document.body.contains(elem)) {
|
|
|
|
|
|
|
|
clearInterval(interval);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
elem.innerHTML = getEndsAt(item);
|
|
|
|
|
|
|
|
}, 60000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function fillPrimaryMediaInfo(elem, item, options) {
|
|
|
|
var html = getPrimaryMediaInfoHtml(item, options);
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
afterFill(elem, item, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
function fillSecondaryMediaInfo(elem, item, options) {
|
|
|
|
var html = getSecondaryMediaInfoHtml(item, options);
|
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
afterFill(elem, item, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
function afterFill(elem, item, options) {
|
|
|
|
|
2016-05-15 18:22:22 -07:00
|
|
|
if (options.endsAt !== false) {
|
|
|
|
var endsAtElem = elem.querySelector('.endsAt');
|
|
|
|
if (endsAtElem) {
|
|
|
|
dynamicEndTime(endsAtElem, item);
|
|
|
|
}
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var lnkChannel = elem.querySelector('.lnkChannel');
|
|
|
|
if (lnkChannel) {
|
|
|
|
lnkChannel.addEventListener('click', onChannelLinkClick);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onChannelLinkClick(e) {
|
|
|
|
|
|
|
|
var channelId = this.getAttribute('data-id');
|
|
|
|
var serverId = this.getAttribute('data-serverid');
|
|
|
|
|
|
|
|
embyRouter.showItem(channelId, serverId);
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPrimaryMediaInfoHtml(item, options) {
|
|
|
|
|
|
|
|
options = options || {};
|
|
|
|
if (options.interactive == null) {
|
|
|
|
options.interactive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return getMediaInfoHtml(item, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSecondaryMediaInfoHtml(item, options) {
|
|
|
|
|
|
|
|
options = options || {};
|
|
|
|
if (options.interactive == null) {
|
|
|
|
options.interactive = false;
|
|
|
|
}
|
|
|
|
if (item.Type == 'Program') {
|
2016-08-29 21:33:24 -07:00
|
|
|
return getProgramInfoHtml(item, options);
|
2016-05-11 15:08:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
getMediaInfoHtml: getPrimaryMediaInfoHtml,
|
|
|
|
fill: fillPrimaryMediaInfo,
|
|
|
|
getEndsAt: getEndsAt,
|
|
|
|
getEndsAtFromPosition: getEndsAtFromPosition,
|
|
|
|
getPrimaryMediaInfoHtml: getPrimaryMediaInfoHtml,
|
|
|
|
getSecondaryMediaInfoHtml: getSecondaryMediaInfoHtml,
|
|
|
|
fillPrimaryMediaInfo: fillPrimaryMediaInfo,
|
|
|
|
fillSecondaryMediaInfo: fillSecondaryMediaInfo
|
|
|
|
};
|
|
|
|
});
|