define(['datetime', 'globalize', 'embyRouter', 'html!./../icons/mediainfo.html'], function (datetime, globalize, embyRouter) {
function getProgramInfoHtml(item, options) {
var html = '';
var miscInfo = [];
var text, date;
if (item.ChannelName) {
if (options.interactive && item.ChannelId) {
miscInfo.push('' + item.ChannelName + '');
} else {
miscInfo.push(item.ChannelName);
}
}
if (item.StartDate) {
try {
date = datetime.parseISO8601Date(item.StartDate);
text = date.toLocaleDateString();
text += ', ' + datetime.getDisplayTime(date);
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);
}
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;
if (item.Type == "MusicAlbum" || item.MediaType == 'MusicArtist' || item.MediaType == 'Playlist' || item.MediaType == 'MusicGenre') {
var count = item.SongCount || item.ChildCount;
if (count) {
miscInfo.push(globalize.translate('core#TrackCount', count));
}
if (item.CumulativeRunTimeTicks) {
miscInfo.push(datetime.getDisplayRunningTime(item.CumulativeRunTimeTicks));
}
}
else if (item.Type == "PhotoAlbum" || item.Type == "BoxSet") {
var count = item.ChildCount;
if (count) {
miscInfo.push(globalize.translate('core#ItemCount', count));
}
}
if (item.Type == "Episode" || item.MediaType == 'Photo') {
if (item.PremiereDate) {
try {
date = datetime.parseISO8601Date(item.PremiereDate);
text = date.toLocaleDateString();
miscInfo.push(text);
}
catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
}
}
if (item.StartDate && item.Type != 'Program') {
try {
date = datetime.parseISO8601Date(item.StartDate);
text = date.toLocaleDateString();
miscInfo.push(text);
if (item.Type != "Recording") {
text = datetime.getDisplayTime(date);
miscInfo.push(text);
}
}
catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
}
if (item.ProductionYear && item.Type == "Series") {
if (item.Status == "Continuing") {
miscInfo.push(globalize.translate('core#ValueSeriesYearToPresent', item.ProductionYear));
}
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') {
if (item.PremiereDate) {
try {
date = datetime.parseISO8601Date(item.PremiereDate);
text = globalize.translate('core#OriginalAirDateValue', date.toLocaleDateString());
miscInfo.push(text);
}
catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
} else if (item.ProductionYear) {
text = globalize.translate('core#ReleaseYearValue', item.ProductionYear);
miscInfo.push(text);
}
}
if (item.Type != "Series" && item.Type != "Episode" && item.Type != "Person" && item.MediaType != 'Photo' && item.Type != 'Program') {
if (item.ProductionYear) {
miscInfo.push(item.ProductionYear);
}
else if (item.PremiereDate) {
try {
text = datetime.parseISO8601Date(item.PremiereDate).getFullYear();
miscInfo.push(text);
}
catch (e) {
console.log("Error parsing date: " + item.PremiereDate);
}
}
}
if (item.RunTimeTicks && item.Type != "Series" && item.Type != 'Program' && options.runtime !== false) {
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.HasSubtitles && options.subtitles !== false) {
miscInfo.push({
html: '