| | 1 | | using System; |
| | 2 | | using System.Globalization; |
| | 3 | | using System.Text; |
| | 4 | | using MediaBrowser.Controller.LiveTv; |
| | 5 | |
|
| | 6 | | namespace Jellyfin.LiveTv.Recordings |
| | 7 | | { |
| | 8 | | internal static class RecordingHelper |
| | 9 | | { |
| | 10 | | public static string GetRecordingName(TimerInfo info) |
| | 11 | | { |
| 9 | 12 | | var name = info.Name; |
| | 13 | |
|
| 9 | 14 | | if (info.IsProgramSeries) |
| | 15 | | { |
| 7 | 16 | | var addHyphen = true; |
| | 17 | |
|
| 7 | 18 | | if (info.SeasonNumber.HasValue && info.EpisodeNumber.HasValue) |
| | 19 | | { |
| 2 | 20 | | name += string.Format( |
| 2 | 21 | | CultureInfo.InvariantCulture, |
| 2 | 22 | | " S{0}E{1}", |
| 2 | 23 | | info.SeasonNumber.Value.ToString("00", CultureInfo.InvariantCulture), |
| 2 | 24 | | info.EpisodeNumber.Value.ToString("00", CultureInfo.InvariantCulture)); |
| 2 | 25 | | addHyphen = false; |
| | 26 | | } |
| 5 | 27 | | else if (info.OriginalAirDate.HasValue) |
| | 28 | | { |
| 4 | 29 | | if (info.OriginalAirDate.Value.Date.Equals(info.StartDate.Date)) |
| | 30 | | { |
| 2 | 31 | | name += " " + GetDateString(info.StartDate); |
| | 32 | | } |
| | 33 | | else |
| | 34 | | { |
| 2 | 35 | | name += " " + info.OriginalAirDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.Invari |
| | 36 | | } |
| | 37 | | } |
| | 38 | | else |
| | 39 | | { |
| 1 | 40 | | name += " " + GetDateString(info.StartDate); |
| | 41 | | } |
| | 42 | |
|
| 7 | 43 | | if (!string.IsNullOrWhiteSpace(info.EpisodeTitle)) |
| | 44 | | { |
| 4 | 45 | | var tmpName = name; |
| 4 | 46 | | if (addHyphen) |
| | 47 | | { |
| 3 | 48 | | tmpName += " -"; |
| | 49 | | } |
| | 50 | |
|
| 4 | 51 | | tmpName += " " + info.EpisodeTitle; |
| | 52 | | // Since the filename will be used with file ext. (.mp4, .ts, etc) |
| 4 | 53 | | if (Encoding.UTF8.GetByteCount(tmpName) < 250) |
| | 54 | | { |
| 3 | 55 | | name = tmpName; |
| | 56 | | } |
| | 57 | | } |
| | 58 | | } |
| 2 | 59 | | else if (info.IsMovie && info.ProductionYear is not null) |
| | 60 | | { |
| 1 | 61 | | name += " (" + info.ProductionYear + ")"; |
| | 62 | | } |
| | 63 | | else |
| | 64 | | { |
| 1 | 65 | | name += " " + GetDateString(info.StartDate); |
| | 66 | | } |
| | 67 | |
|
| 9 | 68 | | return name; |
| | 69 | | } |
| | 70 | |
|
| | 71 | | private static string GetDateString(DateTime date) |
| | 72 | | { |
| 4 | 73 | | return date.ToLocalTime().ToString("yyyy_MM_dd_HH_mm_ss", CultureInfo.InvariantCulture); |
| | 74 | | } |
| | 75 | | } |
| | 76 | | } |