public async Task EmbyWindows_To_EtvLinux_UncPath()
    {
        var replacements = new List <EmbyPathReplacement>
        {
            new()
            {
                Id              = 1,
                EmbyPath        = @"\\192.168.1.100\Something\Some Shared Folder",
                LocalPath       = @"/mnt/something else/Some Shared Folder",
                EmbyMediaSource = new EmbyMediaSource {
                    OperatingSystem = "Windows"
                }
            }
        };

        var repo = new Mock <IMediaSourceRepository>();

        repo.Setup(x => x.GetEmbyPathReplacementsByLibraryId(It.IsAny <int>())).Returns(replacements.AsTask());

        var runtime = new Mock <IRuntimeInfo>();

        runtime.Setup(x => x.IsOSPlatform(OSPlatform.Windows)).Returns(false);

        var service = new EmbyPathReplacementService(
            repo.Object,
            runtime.Object,
            new Mock <ILogger <EmbyPathReplacementService> >().Object);

        string result = await service.GetReplacementEmbyPath(
            0,
            @"\\192.168.1.100\Something\Some Shared Folder\Some Movie\Some Movie.mkv");

        result.Should().Be(@"/mnt/something else/Some Shared Folder/Some Movie/Some Movie.mkv");
    }
Example #2
0
    private Validation <BaseError, ConnectionParameters> MediaSourceMustHaveActiveConnection(
        EmbyMediaSource embyMediaSource)
    {
        Option <EmbyConnection> maybeConnection = embyMediaSource.Connections.HeadOrNone();

        return(maybeConnection.Map(connection => new ConnectionParameters(connection))
               .ToValidation <BaseError>("Emby media source requires an active connection"));
    }
Example #3
0
 internal static EmbyMediaSourceViewModel ProjectToViewModel(EmbyMediaSource embyMediaSource) =>
 private record ConnectionParameters(
     EmbyMediaSource EmbyMediaSource,
     EmbyConnection ActiveConnection);
    private static bool IsWindows(EmbyMediaSource embyMediaSource, string path)
    {
        bool isUnc = Uri.TryCreate(path, UriKind.Absolute, out Uri uri) && uri.IsUnc;

        return(isUnc || embyMediaSource.OperatingSystem.ToLowerInvariant().StartsWith("windows"));
    }