Esempio n. 1
0
    public async Task JellyfinWindows_To_EtvLinux_UncPath()
    {
        var replacements = new List <JellyfinPathReplacement>
        {
            new()
            {
                Id                  = 1,
                JellyfinPath        = @"\\192.168.1.100\Something\Some Shared Folder",
                LocalPath           = @"/mnt/something else/Some Shared Folder",
                JellyfinMediaSource = new JellyfinMediaSource {
                    OperatingSystem = "Windows"
                }
            }
        };

        var repo = new Mock <IMediaSourceRepository>();

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

        var runtime = new Mock <IRuntimeInfo>();

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

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

        string result = await service.GetReplacementJellyfinPath(
            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");
    }
Esempio n. 2
0
    private Validation <BaseError, ConnectionParameters> MediaSourceMustHaveActiveConnection(
        JellyfinMediaSource jellyfinMediaSource)
    {
        Option <JellyfinConnection> maybeConnection = jellyfinMediaSource.Connections.HeadOrNone();

        return(maybeConnection.Map(connection => new ConnectionParameters(jellyfinMediaSource, connection))
               .ToValidation <BaseError>("Jellyfin media source requires an active connection"));
    }
Esempio n. 3
0
 internal static JellyfinMediaSourceViewModel ProjectToViewModel(JellyfinMediaSource jellyfinMediaSource) =>
 private record ConnectionParameters(
     JellyfinMediaSource JellyfinMediaSource,
     JellyfinConnection ActiveConnection);
    private static bool IsWindows(JellyfinMediaSource jellyfinMediaSource, string path)
    {
        bool isUnc = Uri.TryCreate(path, UriKind.Absolute, out Uri uri) && uri.IsUnc;

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