define([
"exports",
"./../common/datetime.js",
"./../common/globalize.js",
"./../common/textencoding.js",
"./../common/itemhelper.js",
"./../common/itemmanager/itemmanager.js",
"./../indicators/indicators.js",
"./../approuter.js",
"./../emby-elements/emby-button/emby-button.js",
"./../common/dataformatter.js",
], function (
_exports,
_datetime,
_globalize,
_textencoding,
_itemhelper,
_itemmanager,
_indicators,
_approuter,
_embyButton,
_dataformatter,
) {
function getProgramInfoHtml(item, options) {
var date,
text,
html = "",
miscInfo = [];
if (item.StartDate && !1 !== options.programTime)
try {
(text = ""),
(date = new Date(Date.parse(item.StartDate))),
!1 !== options.startDate &&
(text += _datetime.default.toLocaleDateString(date, {
weekday: "short",
month: "short",
day: "numeric",
})),
(text += " " + _datetime.default.getDisplayTime(date)),
item.EndDate &&
((date = new Date(Date.parse(item.EndDate))),
(text += " – " + _datetime.default.getDisplayTime(date))),
miscInfo.push(text);
} catch (e) {
console.log("Error parsing date: " + item.StartDate);
}
return (
item.ChannelName &&
((date = item.ChannelName),
item.ChannelNumber && (date += " " + item.ChannelNumber),
options.interactive && item.ChannelId
? miscInfo.push({
html:
'' +
date +
"",
})
: miscInfo.push(date)),
options.timerIndicator &&
(text = (function (item) {
var status,
itemType = item.Type;
if ("SeriesTimer" === itemType)
return '';
if (item.TimerId || item.SeriesTimerId)
status = item.Status || "Cancelled";
else {
if ("Timer" !== itemType) return "";
status = item.Status;
}
return item.SeriesTimerId
? "Cancelled" !== status
? ''
: ''
: '';
})(item)) &&
miscInfo.push({ html: text }),
(html += miscInfo.map(getMediaInfoItem).join(""))
);
}
function getMediaInfoHtml(item, options) {
var showFolderRuntime,
html = "",
miscInfo = [],
itemType = ((options = options || {}), item.Type);
switch (itemType) {
case "MusicAlbum":
case "MusicArtist":
case "Playlist":
case "MusicGenre":
case "BoxSet":
showFolderRuntime = !0;
}
if (
("Episode" === itemType || "Photo" === item.MediaType) &&
!1 !== options.originalAirDate &&
item.PremiereDate
)
try {
(date = new Date(Date.parse(item.PremiereDate))),
(text = _datetime.default.toLocaleDateString(date, {
month: "short",
day: "numeric",
year: "numeric",
})),
miscInfo.push(text);
} catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
if (
("SeriesTimer" === itemType &&
(item.RecordAnyTime
? miscInfo.push(_globalize.default.translate("Anytime"))
: item.StartDate &&
miscInfo.push(_datetime.default.getDisplayTime(item.StartDate)),
item.RecordAnyChannel ||
null == (_item$ChannelIds = item.ChannelIds) ||
!_item$ChannelIds.length
? miscInfo.push(_globalize.default.translate("AllChannels"))
: miscInfo.push(
item.ChannelName || _globalize.default.translate("OneChannel"),
)),
item.StartDate &&
"Program" !== itemType &&
"SeriesTimer" !== itemType &&
"Timer" !== itemType)
)
try {
(date = new Date(Date.parse(item.StartDate))),
(text = _datetime.default.toLocaleDateString(date, {
month: "short",
day: "numeric",
year: "numeric",
})),
miscInfo.push(text),
"Recording" !== itemType &&
((text = _datetime.default.getDisplayTime(date)),
miscInfo.push(text));
} catch (e) {
console.log("Error parsing date: " + item.StartDate);
}
if (!1 !== options.year && item.ProductionYear && "Series" === itemType)
if ("Continuing" === item.Status)
miscInfo.push(
_globalize.default.translate(
"SeriesYearToPresent",
item.ProductionYear,
),
);
else if (item.ProductionYear) {
if (((text = item.ProductionYear), item.EndDate))
try {
var endYear = new Date(Date.parse(item.EndDate)).getFullYear();
endYear !== item.ProductionYear && (text += " – " + endYear);
} catch (e) {
console.log("Error parsing date: " + item.EndDate);
}
miscInfo.push(text);
}
if (
("Series" === itemType &&
((_item$ChannelIds = ""),
item.Studios &&
item.Studios.length &&
((endYear = item.Studios[0]),
_item$ChannelIds && (_item$ChannelIds += " on "),
(_item$ChannelIds +=
'' +
endYear.Name +
"")),
_item$ChannelIds) &&
miscInfo.push(_item$ChannelIds),
!1 !== options.programIndicator &&
(item.IsLive
? miscInfo.push({
html:
'
' +
_globalize.default.translate("Live") +
"
",
})
: item.IsPremiere
? miscInfo.push({
html:
'' +
_globalize.default.translate("Premiere") +
"
",
})
: item.IsNew
? miscInfo.push({
html:
'' +
_globalize.default.translate("AttributeNew") +
"
",
})
: item.IsRepeat &&
miscInfo.push({
html:
'' +
_globalize.default.translate("Repeat") +
"
",
})),
"Program" === itemType)
)
if ((item.IsSeries || item.EpisodeTitle) && !1 !== options.episodeTitle)
(text = _itemmanager.default.getDisplayName(item, {
includeIndexNumber: options.episodeTitleIndexNumber,
})) && miscInfo.push(text);
else if (
item.IsMovie &&
item.ProductionYear &&
!1 !== options.originalAirDate
)
miscInfo.push(item.ProductionYear);
else if (item.PremiereDate && !1 !== options.originalAirDate)
try {
(date = new Date(Date.parse(item.PremiereDate))),
(text = _globalize.default.translate(
"OriginalAirDateValue",
_datetime.default.toLocaleDateString(date, {
month: "short",
day: "numeric",
year: "numeric",
}),
)),
miscInfo.push(text);
} catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
else item.ProductionYear && miscInfo.push(item.ProductionYear);
if (
!1 !== options.year &&
"Series" !== itemType &&
("Episode" !== itemType || !item.PremiereDate) &&
"Person" !== itemType &&
"Photo" !== item.MediaType &&
"Program" !== itemType &&
"Season" !== itemType
)
if (item.ProductionYear) miscInfo.push(item.ProductionYear);
else if (item.PremiereDate)
try {
(text = new Date(Date.parse(item.PremiereDate)).getFullYear()),
miscInfo.push(text);
} catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
var date,
_item$ChannelIds =
(null == (endYear = options.mediaSource)
? void 0
: endYear.RunTimeTicks) || item.RunTimeTicks,
text =
("Series" === itemType ||
"Program" === itemType ||
showFolderRuntime ||
!1 === options.runtime ||
(_item$ChannelIds &&
miscInfo.push(
"Audio" === itemType
? _datetime.default.getDisplayRunningTime(_item$ChannelIds)
: _datetime.default.getHumanReadableRuntime(_item$ChannelIds),
)),
item.OfficialRating && miscInfo.push(item.OfficialRating),
showFolderRuntime &&
((date = item.SongCount || item.ChildCount) &&
miscInfo.push(
"BoxSet" === itemType
? 1 === date
? _globalize.default.translate("ValueOneItem")
: _globalize.default.translate("ItemCount", date)
: 1 === date
? _globalize.default.translate("OneTrack")
: _globalize.default.translate("TrackCount", date),
),
_item$ChannelIds) &&
"Playlist" === itemType &&
miscInfo.push(
_datetime.default.getHumanReadableRuntime(_item$ChannelIds),
),
"Series" === itemType &&
item.ChildCount &&
(1 === item.ChildCount
? miscInfo.push(_globalize.default.translate("OneSeason"))
: miscInfo.push(
_globalize.default.translate(
"NumberSeasonsValue",
item.ChildCount,
),
)),
item.Video3DFormat && miscInfo.push("3D"),
"Photo" === item.MediaType &&
item.Width &&
item.Height &&
miscInfo.push(item.Width + "x" + item.Height),
options.container &&
item.Container &&
miscInfo.push(item.Container.toUpperCase()),
item.Bitrate || item.BitRate);
return (
options.bitrate &&
text &&
miscInfo.push(_dataformatter.default.bitrateToString(text)),
"RemoteSubtitle" === itemType &&
(null != item.DownloadCount &&
miscInfo.push(
_globalize.default.translate("DownloadsValue", item.DownloadCount),
),
item.IsForced &&
(html +=
'' +
_globalize.default.translate("Forced") +
"
"),
item.IsHashMatch) &&
(html +=
'' +
_globalize.default.translate("HashMatch") +
"
"),
!1 !== options.CommunityRating &&
item.CommunityRating &&
"RemoteSubtitle" !== item.Type &&
(html += getStarIconsHtml(item)),
item.CriticRating &&
!1 !== options.criticRating &&
(html += getCriticRating(item)),
(html += miscInfo.map(getMediaInfoItem).join("")),
item.HasSubtitles &&
!1 !== options.subtitles &&
(html +=
'CC
'),
options.dateAdded &&
_itemhelper.default.enableDateAddedDisplay(item) &&
((endYear = new Date(Date.parse(item.DateCreated))),
(html += getMediaInfoItem(
_globalize.default.translate(
"AddedOnValue",
_datetime.default.toLocaleDateString(endYear, {
month: "short",
day: "numeric",
year: "numeric",
}),
),
))),
options.genres &&
(html += (function (item, options) {
var type,
context = options.context,
genres = (item.GenreItems || []).slice(0),
itemType = item.Type;
switch (
(("Playlist" !== itemType &&
"BoxSet" !== itemType &&
"MusicArtist" !== itemType) ||
(5 < genres.length && (genres.length = 5)),
context)
) {
case "games":
type = "GameGenre";
break;
case "music":
type = "MusicGenre";
break;
default:
type = "Genre";
}
return (
(itemType = options.genreConcat || ", "),
(options =
(options = genres
.map(function (p) {
return (
'' +
_textencoding.default.htmlEncode(p.Name) +
""
);
})
.join(itemType)) &&
'' +
options +
"
")
);
})(item, options)),
!1 !== options.endsAt &&
(date = getEndsAt(item, options.mediaSource)) &&
(html += getMediaInfoItem(
date,
("endsAt " + (options.endsAtClass || "")).trim(),
)),
(html += _indicators.default.getMissingIndicator(item))
);
}
function getEndsAt(item, mediaSource) {
if (
((mediaSource = mediaSource || item),
"Video" === item.MediaType && mediaSource.RunTimeTicks) &&
!item.StartDate &&
"Program" !== item.Type
)
return (
(item = (item.UserData && item.UserData.PlaybackPositionTicks) || 0),
getEndsAtFromPosition(mediaSource.RunTimeTicks, item)
);
return null;
}
function getEndsAtFromPosition(runtimeTicks, positionTicks, includeText) {
(runtimeTicks = Date.now() + (runtimeTicks - (positionTicks || 0)) / 1e4),
(runtimeTicks = new Date(runtimeTicks)),
(positionTicks = _datetime.default.getDisplayTime(runtimeTicks));
return !1 === includeText
? positionTicks
: _globalize.default.translate("EndsAtValue", positionTicks);
}
function getMediaInfoItem(m, cssClass) {
cssClass =
"string" == typeof cssClass
? cssClass + " mediaInfoItem"
: "mediaInfoItem";
var mediaInfoText = m;
if ("string" != typeof m && "number" != typeof m) {
if (m.html) return m.html;
(mediaInfoText = m.text), (cssClass += " " + m.cssClass);
}
return '' + mediaInfoText + "
";
}
function getCriticRating(item, options) {
var outerClass = "mediaInfoItem mediaInfoCriticRating";
return (
options && options.outerClass && (outerClass += " " + options.outerClass),
'' +
item.CriticRating +
"%
"
);
}
function getStarIconsHtml(item, options) {
var outerClass,
html = "",
item = item.CommunityRating;
return (
item &&
((outerClass = "starRatingContainer mediaInfoItem"),
options &&
options.outerClass &&
(outerClass += " " + options.outerClass),
(html =
(html =
html +
'') +
_dataformatter.default.numberToString(item, 1) +
"
")),
html
);
}
function fillPrimaryMediaInfo(elem, item, options) {
var html = getPrimaryMediaInfoHtml(item, options);
(elem.innerHTML = html)
? elem.classList.remove("hide")
: elem.classList.add("hide"),
afterFill(elem, item, options);
}
function afterFill(elem, item, options) {
!1 !== options.endsAt &&
(elem = elem.querySelector(".endsAt")) &&
!(function (elem, item, mediaSource) {
var interval = setInterval(function () {
document.body.contains(elem)
? (elem.innerHTML = getEndsAt(item, mediaSource))
: clearInterval(interval);
}, 6e4);
})(elem, item, options.mediaSource);
}
function getPrimaryMediaInfoHtml(item, options) {
return (
null == (options = options || {}).interactive &&
(options.interactive = !1),
getMediaInfoHtml(item, options)
);
}
function getSecondaryMediaInfoHtml(item, options) {
null == (options = options || {}).interactive && (options.interactive = !1);
var itemType = item.Type;
return "Program" === itemType ||
"Timer" === itemType ||
"Recording" === itemType
? getProgramInfoHtml(item, options)
: "";
}
function createAttribute(label, value, className) {
return (
'' +
label +
'' +
value +
"
"
);
}
Object.defineProperty(_exports, "__esModule", { value: !0 }),
(_exports.default = void 0),
require([
"material-icons",
"css!modules/mediainfo/mediainfo.css",
"programStyles",
]);
var _default = {
getMediaInfoHtml: getPrimaryMediaInfoHtml,
fill: fillPrimaryMediaInfo,
getEndsAt: getEndsAt,
getEndsAtFromPosition: getEndsAtFromPosition,
getPrimaryMediaInfoHtml: getPrimaryMediaInfoHtml,
getSecondaryMediaInfoHtml: getSecondaryMediaInfoHtml,
fillPrimaryMediaInfo: fillPrimaryMediaInfo,
fillSecondaryMediaInfo: function (elem, item, options) {
var html = getSecondaryMediaInfoHtml(item, options);
(elem.innerHTML = html)
? elem.classList.remove("hide")
: elem.classList.add("hide"),
afterFill(elem, item, options);
},
getResolutionText: _dataformatter.default.getResolutionText,
pushMediaStreamLines: function (stream, options, lines, icon) {
var streamType = stream.StreamType,
streamTypeLocalizationKey =
"EmbeddedImage" === streamType ? "Image" : streamType,
streamTypeLocalizationKey =
("Lyrics" === stream.SubtitleType &&
(streamTypeLocalizationKey = "Lyrics"),
_globalize.default.translate(streamTypeLocalizationKey));
lines.push(
'' +
(streamTypeLocalizationKey = icon
? '' +
icon +
"" +
streamTypeLocalizationKey
: streamTypeLocalizationKey) +
"
",
),
stream.DisplayTitle &&
lines.push(
createAttribute(
_globalize.default.translate("Title"),
stream.DisplayTitle,
),
),
stream.Title &&
stream.Title !== stream.DisplayTitle &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderEmbeddedTitle"),
stream.Title,
),
),
(stream.DisplayLanguage || stream.Language) &&
"Video" !== streamType &&
lines.push(
createAttribute(
_globalize.default.translate("Language"),
stream.DisplayLanguage || stream.Language,
),
),
stream.Codec &&
lines.push(
createAttribute(
_globalize.default.translate("Codec"),
stream.Codec.toUpperCase(),
),
),
stream.CodecTag &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderCodecTag"),
stream.CodecTag,
),
),
stream.Profile &&
lines.push(
createAttribute(
_globalize.default.translate("Profile"),
stream.Profile,
),
),
stream.Level &&
lines.push(
createAttribute(
_globalize.default.translate("Level"),
stream.Level,
),
),
(stream.Width || stream.Height) &&
lines.push(
createAttribute(
_globalize.default.translate("Resolution"),
stream.Width + "x" + stream.Height,
),
),
stream.AspectRatio &&
"mjpeg" !== stream.Codec &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderAspectRatio"),
stream.AspectRatio,
),
),
"Video" === streamType &&
lines.push(
createAttribute(
_globalize.default.translate("Interlaced"),
stream.IsInterlaced
? _globalize.default.translate("Yes")
: _globalize.default.translate("No"),
),
),
(stream.AverageFrameRate || stream.RealFrameRate) &&
lines.push(
createAttribute(
_globalize.default.translate("Framerate"),
_dataformatter.default.numberToString(
stream.AverageFrameRate || stream.RealFrameRate,
3,
),
),
),
stream.ChannelLayout &&
lines.push(
createAttribute(
_globalize.default.translate("Layout"),
stream.ChannelLayout,
),
),
stream.Channels &&
lines.push(
createAttribute(
_globalize.default.translate("Channels"),
stream.Channels + " ch",
),
),
stream.BitRate &&
"mjpeg" !== stream.Codec &&
lines.push(
createAttribute(
_globalize.default.translate("Bitrate"),
_dataformatter.default.bitrateToString(stream.BitRate),
),
),
stream.SampleRate &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderSampleRate"),
_dataformatter.default.numberToString(stream.SampleRate) + " Hz",
),
),
stream.VideoRange &&
"SDR" !== stream.VideoRange &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderVideoRange"),
stream.VideoRange,
),
),
stream.ColorPrimaries &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderColorPrimaries"),
stream.ColorPrimaries,
),
),
stream.ColorSpace &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderColorSpace"),
stream.ColorSpace,
),
),
stream.ColorTransfer &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderColorTransfer"),
stream.ColorTransfer,
),
),
stream.BitDepth &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderBitDepth"),
stream.BitDepth + " bit",
),
),
stream.PixelFormat &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderPixelFormat"),
stream.PixelFormat,
),
),
stream.RefFrames &&
lines.push(
createAttribute(
_globalize.default.translate("HeaderReferenceFrames"),
stream.RefFrames,
),
),
stream.Rotation &&
lines.push(
createAttribute(
_globalize.default.translate("Rotation"),
stream.Rotation,
),
),
"Video" !== streamType &&
lines.push(
createAttribute(
_globalize.default.translate("Default"),
stream.IsDefault
? _globalize.default.translate("Yes")
: _globalize.default.translate("No"),
),
),
"Subtitle" === streamType &&
("Lyrics" !== stream.SubtitleType &&
lines.push(
createAttribute(
_globalize.default.translate("Forced"),
stream.IsForced
? _globalize.default.translate("Yes")
: _globalize.default.translate("No"),
),
),
lines.push(
createAttribute(
_globalize.default.translate("External"),
stream.IsExternal
? _globalize.default.translate("Yes")
: _globalize.default.translate("No"),
),
)),
stream.IsExternal &&
stream.Path &&
lines.push(
createAttribute(
_globalize.default.translate("File"),
(function (stream) {
return (stream = stream.Path.split("/").join("\\").split("\\"))[
stream.length - 1
];
})(stream),
),
);
},
getCommunityRating: getStarIconsHtml,
getCriticRating: getCriticRating,
bitrateToString: _dataformatter.default.bitrateToString,
sizeToString: _dataformatter.default.sizeToString,
};
_exports.default = _default;
});