Add test for year-only parsing for FFProbe

This commit is contained in:
MrTimscampi 2021-08-07 22:24:10 +02:00
parent ba609aefea
commit 924dfe1db0
2 changed files with 167 additions and 0 deletions

View File

@ -71,5 +71,25 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
Assert.True(res.PremiereDate.HasValue);
Assert.Equal(DateTime.Parse("2021-01-01T00:00Z", DateTimeFormatInfo.CurrentInfo).ToUniversalTime(), res.PremiereDate);
}
[Fact]
public void GetMediaInfo_Music_Year_Only_Success()
{
var bytes = File.ReadAllBytes("Test Data/Probing/music_year_only_metadata.json");
var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions);
MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, null, true, "Test Data/Probing/music.flac", MediaProtocol.File);
Assert.Equal("Baker Street", res.Name);
Assert.Single(res.Artists);
Assert.Equal("Gerry Rafferty", res.Artists[0]);
Assert.Equal("City to City", res.Album);
Assert.Equal(1978, res.ProductionYear);
Assert.True(res.PremiereDate.HasValue);
Assert.Equal(DateTime.Parse("1978-01-01T00:00Z", DateTimeFormatInfo.CurrentInfo).ToUniversalTime(), res.PremiereDate);
Assert.Contains("Electronic", res.Genres);
Assert.Contains("Ambient", res.Genres);
Assert.Contains("Pop", res.Genres);
Assert.Contains("Jazz", res.Genres);
}
}
}

View File

@ -0,0 +1,147 @@
{
"streams": [
{
"index": 0,
"codec_name": "flac",
"codec_long_name": "FLAC (Free Lossless Audio Codec)",
"codec_type": "audio",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 16394616,
"duration": "371.760000",
"bits_per_raw_sample": "16",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
},
{
"index": 1,
"codec_name": "mjpeg",
"codec_long_name": "Motion JPEG",
"profile": "Baseline",
"codec_type": "video",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"width": 500,
"height": 498,
"coded_width": 500,
"coded_height": 498,
"closed_captions": 0,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "250:249",
"pix_fmt": "yuvj420p",
"level": -99,
"color_range": "pc",
"color_space": "bt470bg",
"chroma_location": "center",
"refs": 1,
"r_frame_rate": "90000/1",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 33458400,
"duration": "371.760000",
"bits_per_raw_sample": "8",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 1,
"timed_thumbnails": 0
},
"tags": {
"comment": "Cover (front)"
}
}
],
"format": {
"filename": "02 Baker Street.flac",
"nb_streams": 2,
"nb_programs": 0,
"format_name": "flac",
"format_long_name": "raw FLAC",
"start_time": "0.000000",
"duration": "371.760000",
"size": "37072649",
"bit_rate": "797775",
"probe_score": 100,
"tags": {
"MUSICBRAINZ_RELEASEGROUPID": "238c3fb4-5792-342b-b217-02f66298b424",
"ORIGINALDATE": "1978",
"ORIGINALYEAR": "1978",
"RELEASETYPE": "album",
"MUSICBRAINZ_ALBUMID": "30156786-e511-3106-ac95-66f0e880b24b",
"ASIN": "B000007O5H",
"MUSICBRAINZ_ALBUMARTISTID": "563201cb-721c-4cfb-acca-c1ba69e3d1fb",
"album_artist": "Gerry Rafferty",
"ALBUMARTISTSORT": "Rafferty, Gerry",
"LABEL": "Liberty EMI Records UK",
"CATALOGNUMBER": "CDP 7 46049 2",
"DATE": "1989-07-26",
"RELEASECOUNTRY": "GB",
"BARCODE": "077774604925",
"ALBUM": "City to City",
"SCRIPT": "Latn",
"RELEASESTATUS": "official",
"TOTALDISCS": "1",
"disc": "1",
"MEDIA": "CD",
"TOTALTRACKS": "10",
"MUSICBRAINZ_TRACKID": "9235e22e-afbd-48f7-b329-21dae6da2810",
"ISRC": "GBAYE1100924;GBAYE7800619",
"PERFORMER": "Hugh Burns (electric guitar);Nigel Jenkins (electric guitar);Tommy Eyre (keyboard and Moog);Glen LeFleur (percussion);Raphael Ravenscroft (saxophone);Henry Spinetti (drums (drum set));Gary Taylor (bass);Gerry Rafferty (lead vocals)",
"ARRANGER": "Graham Preskett",
"MIXER": "Declan ODoherty",
"PRODUCER": "Hugh Murphy;Gerry Rafferty",
"MUSICBRAINZ_WORKID": "a9eb3c45-784c-3c32-860c-4b406f03961b",
"LANGUAGE": "eng",
"WORK": "Baker Street",
"COMPOSER": "Gerry Rafferty",
"COMPOSERSORT": "Rafferty, Gerry",
"LYRICIST": "Gerry Rafferty",
"TITLE": "Baker Street",
"MUSICBRAINZ_ARTISTID": "563201cb-721c-4cfb-acca-c1ba69e3d1fb",
"ARTIST": "Gerry Rafferty",
"ARTISTSORT": "Rafferty, Gerry",
"ARTISTS": "Gerry Rafferty",
"MUSICBRAINZ_RELEASETRACKID": "407cf7f7-440d-3e76-8b89-8686198868ea",
"track": "2",
"GENRE": "Electronic;Ambient;Pop;Jazz",
"WEBSITE": "http://www.gerryrafferty.com/",
"ACOUSTID_ID": "68f8d979-a659-4aa0-a216-eb3721a951eb",
"MOOD": "Acoustic;Not aggressive;Not electronic;Not happy;Party;Relaxed;Not sad",
"TRACKTOTAL": "10",
"DISCTOTAL": "1"
}
}
}