Beispiel #1
0
        public SyncCache(RemoteService remoteService)
        {
            _remoteService = remoteService;

            _cachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MediaManager");
            _cacheFile = Path.Combine(_cachePath, "cache.xml");
        }
Beispiel #2
0
        private static bool ValidateArgs(string[] args)
        {
            // config file can override any changes
            if (LoadArgsFromConfig())
            {
                _remoteService = new RemoteService(_webServiceUrl, _serverKey);
                return true;
            }

            if (args == null || (args.Length == 1 && args[0] == "-a") || args.Length < 3)
            {
                System.Console.WriteLine("Please provide which action you'd like to run.");
                System.Console.WriteLine("-a agent mode, automated linking to the cloud server");
                System.Console.WriteLine("=============================================================================");
                System.Console.WriteLine("Remaing modes are forced manual actions, ignores pending commands from server");
                System.Console.WriteLine("=============================================================================");
                System.Console.WriteLine("-s syncing");
                System.Console.WriteLine("-r refresh local cache");
                System.Console.WriteLine("-t remote transcoding");
                System.Console.WriteLine("-i import of new media files");
                System.Console.WriteLine("-c convert for mpeg2video to x264 encoding");
                System.Console.WriteLine("-d drive agent, reports to the server changes");
                System.Console.WriteLine("-md move files to target drive");
                System.Console.WriteLine("-mi import files from target drive");

                System.Console.WriteLine("mediamanagerclient.exe -a");
                System.Console.WriteLine("mediamanagerclient.exe -s {url} {server key} {local server} {exclusions}");
                System.Console.WriteLine("mediamanagerclient.exe -r {url} {server key}");
                System.Console.WriteLine("mediamanagerclient.exe -t {url} {server key} {output folder}");
                System.Console.WriteLine("mediamanagerclient.exe -i {url} {server key} {import directory} {sorting} {movies archive} {shows archive}");
                System.Console.WriteLine("mediamanagerclient.exe -c {url} {server key} {import directory} {output}");
                System.Console.WriteLine("mediamanagerclient.exe -d {url} {server key}");
                System.Console.WriteLine("mediamanagerclient.exe -md {url} {server key}");
                System.Console.WriteLine("mediamanagerclient.exe -mi {url} {server key} {import directory}");

                return false;
            }

            _webServiceUrl = args[1];
            _serverKey = args[2];

            // initialize the remote service
            _remoteService = new RemoteService(_webServiceUrl, _serverKey);

            switch (args[0])
            {
                // agent mode
                case "-a":

                    break;

                // syncing to cloud service
                case "-s":
                    if (args.Length != 4 && args.Length != 5)
                    {
                        System.Console.WriteLine("Usage for Syncing:");
                        System.Console.WriteLine("{url} url of the web service");
                        System.Console.WriteLine("{server key} key needed to access the web service");
                        System.Console.WriteLine("{local server} address to the plex server (including port)");
                        System.Console.WriteLine("{exclusions} optional, comma seperated list of library ids to exclude from media scan");
                        System.Console.WriteLine("mediamanagerclient.exe -s {url} {server key} {local server} {exclusions}");

                        return false;
                    }

                    _localUrl = args[3];

                    if (args.Length == 5 && args[4] != null)
                    {
                        _syncExclusions = args[4].Split(',').Select(a => Convert.ToInt32(a)).ToList();
                    }

                    break;
                case "-r":

                    break;
                // perform remote transcoding
                case "-t":
                    if (args.Length != 3)
                    {
                        System.Console.WriteLine("Usage for remote transcoding:");
                        System.Console.WriteLine("{url} url of the web service");
                        System.Console.WriteLine("{server key} key needed to access the web service");
                        System.Console.WriteLine("{output folder} where to put the encoded file");
                        System.Console.WriteLine("mediamanagerclient.exe -t {url} {server key} {output folder}");

                        return false;
                    }

                    _outputDirectory = args[3];

                    break;
                // import new files
                case "-i":
                    if (args.Length != 6 && args.Length != 7)
                    {
                        System.Console.WriteLine("Usage for remote import:");
                        System.Console.WriteLine("{url} url of the web service");
                        System.Console.WriteLine("{server key} key needed to access the web service");
                        System.Console.WriteLine("{import directory} source folder to go looking for files");
                        System.Console.WriteLine("{sorting} folder for sorting movies/tv shows");
                        System.Console.WriteLine("{movies archive} folder for permanent archive storage");
                        System.Console.WriteLine("{shows archive} folder for permanent archive storage (defaults to movies if not provided)");
                        System.Console.WriteLine("mediamanagerclient.exe -i {url} {server key} {src} {sorting} {movies archive} {shows archive}");

                        return false;
                    }

                    _importDirectory = args[3];
                    _sortingDirectory = args[4];
                    _moviesArchive = args[5];
                    _showsArchive = args[6] ?? args[5];

                    break;
                // batch transcoding
                //case "-c":
                //    if (args.Length != 6)
                //    {
                //        System.Console.WriteLine("Usage for remote mpeg2video to x264 encoding:");
                //        System.Console.WriteLine("{url} url of the web service");
                //        System.Console.WriteLine("{server key} key needed to access the web service");
                //        System.Console.WriteLine("{localUrl} address to plex server");
                //        System.Console.WriteLine("{archive} directory to archive original file");
                //        System.Console.WriteLine("{libraryId} library id");
                //        System.Console.WriteLine("mediamanagerclient.exe -c {url} {server key} {src} {archive} {libraryId}");
                //    }

                //    _localUrl = args[3];
                //    _moviesArchive = args[4];
                //    int.TryParse(args[5], out _libraryId);

                //    break;

                case "-d":

                    break;

                case "-md":
                    break;

                case "-mi":

                    if (args.Length != 4)
                    {
                        System.Console.WriteLine("Usage for import from drive:");
                        System.Console.WriteLine("{url} url of the web service");
                        System.Console.WriteLine("{server key} key needed to access the web service");
                        System.Console.WriteLine("{import directory} directory to copy files, should be same as that used by import so it gets automated");
                        System.Console.WriteLine("mediamanagerclient.exe -mi {url} {server key} {import directory}");
                    }

                    _importDirectory = args[3];

                    break;

                default:
                    return false;
            }

            return true;
        }