{"action":"opened","issue":{"url":"https://api.github.com/repos/Sonarr/Sonarr/issues/1967","repository_url":"https://api.github.com/repos/Sonarr/Sonarr","labels_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/1967/labels{/name}","comments_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/1967/comments","events_url":"https://api.github.com/repos/Sonarr/Sonarr/issues/1967/events","html_url":"https://github.com/Sonarr/Sonarr/issues/1967","id":235003540,"number":1967,"title":"Fix for missing libmediainfo.so.0 causing bad sample detection","user":{"login":"smcpeck","id":8724583,"avatar_url":"https://avatars2.githubusercontent.com/u/8724583?v=3","gravatar_id":"","url":"https://api.github.com/users/smcpeck","html_url":"https://github.com/smcpeck","followers_url":"https://api.github.com/users/smcpeck/followers","following_url":"https://api.github.com/users/smcpeck/following{/other_user}","gists_url":"https://api.github.com/users/smcpeck/gists{/gist_id}","starred_url":"https://api.github.com/users/smcpeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smcpeck/subscriptions","organizations_url":"https://api.github.com/users/smcpeck/orgs","repos_url":"https://api.github.com/users/smcpeck/repos","events_url":"https://api.github.com/users/smcpeck/events{/privacy}","received_events_url":"https://api.github.com/users/smcpeck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-10T13:41:31Z","updated_at":"2017-06-10T13:41:31Z","closed_at":null,"body":"Looking at `/src/NzbDrone.Core/MediaFiles/EpisodeImport/DetectSample.cs`, I am seeing what seems to be a defect.\r\n\r\nI've suffered the unfortunate issue where `libmediainfo.so.0` isn't being properly consumed.  Obviously, this is a configuration issue, however, I got curious as to why the lack of the library causes good media to be erroneously detected as a sample.\r\n\r\nThat led me to the chunk of code below in the file mentioned above:\r\n`            try\r\n            {\r\n                var runTime = _videoFileInfoReader.GetRunTime(path);\r\n                var minimumRuntime = GetMinimumAllowedRuntime(series);\r\n\r\n                if (runTime.TotalMinutes.Equals(0))\r\n                {\r\n                    _logger.Error(\"[{0}] has a runtime of 0, is it a valid video file?\", path);\r\n                    return true;\r\n                }\r\n\r\n                if (runTime.TotalSeconds < minimumRuntime)\r\n                {\r\n                    _logger.Debug(\"[{0}] appears to be a sample. Runtime: {1} seconds. Expected at least: {2} seconds\", path, runTime, minimumRuntime);\r\n                    return true;\r\n                }\r\n            }\r\n\r\n            catch (DllNotFoundException)\r\n            {\r\n                _logger.Debug(\"Falling back to file size detection\");\r\n\r\n                return CheckSize(size, quality);\r\n            }`\r\n\r\nThe first line here in the **try** block tries to get the media's runtime.  This fails and ends up returning 0.  If you look in `VideoFileInfoReader.cs` you will see:\r\n`            catch (DllNotFoundException ex)\r\n            {\r\n                _logger.Error(ex, \"mediainfo is required but was not found\");\r\n            }`\r\n\r\nSo the **catch** in the `DetectSample.cs` snippet above never actually happens in this case.  My thought is that simply adding `throw;` to the `VideoFileInfoReader.cs` catch of the DllNotFoundException would fix this exception.\r\n\r\nJust wanted to get my analysis added here for someone to potentially put into action.  I'm lazy right now, but maybe someday I'll actually clone the repo and add this one line of code.  😆 "}}
{"actor":{"display_login":"smcpeck"}}