コード例 #1
0
        private void LoadLegacyMovie(string filename, string archive = null)
        {
            if (Global.Emulator.IsNull())
            {
                OpenRom();
            }

            if (Global.Emulator.IsNull())
            {
                return;
            }

            // tries to open a legacy movie format by importing it
            var movie = MovieImport.ImportFile(filename, out var errorMsg, out var warningMsg);

            if (!string.IsNullOrEmpty(errorMsg))
            {
                MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // Fix movie extension to something palatable for these purposes.
                // For instance, something which doesn't clobber movies you already may have had.
                // I'm evenly torn between this, and a file in %TEMP%, but since we don't really have a way to clean up this tempfile, I choose this:
                StartNewMovie(movie, false);
            }

            GlobalWin.OSD.AddMessage(warningMsg);
        }
コード例 #2
0
        public async Task <string> UpsertTaxonomy(Movie movie, string listing_prediction)
        {
            MovieImport stronglyTypedElements = new MovieImport
            {
                ListedIn = new[] { TaxonomyTermIdentifier.ByCodename(listing_prediction) }
            };

            // Specifies the content item and the language variant
            ContentItemIdentifier        itemIdentifier     = ContentItemIdentifier.ByCodename(movie.System.Codename);
            LanguageIdentifier           languageIdentifier = LanguageIdentifier.ByCodename(movie.System.Language);
            ContentItemVariantIdentifier identifier         = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);

            // Upserts a language variant of your content item
            ContentItemVariantModel <MovieImport> response = await client.UpsertContentItemVariantAsync(identifier, stronglyTypedElements);

            return(response.Elements.Title + " updated.");
        }
コード例 #3
0
        private void ProcessFileList(IEnumerable <string> fileList, ref Dictionary <LoadOrdering, List <FileInformation> > sortedFiles, string archive = null)
        {
            foreach (string file in fileList)
            {
                var             ext             = Path.GetExtension(file)?.ToUpperInvariant() ?? "";
                FileInformation fileInformation = new FileInformation(Path.GetDirectoryName(file), Path.GetFileName(file), archive);

                switch (ext)
                {
                case ".LUA":
                    sortedFiles[LoadOrdering.LuaScript].Add(fileInformation);
                    break;

                case ".LUASES":
                    sortedFiles[LoadOrdering.LuaSession].Add(fileInformation);
                    break;

                case ".STATE":
                    sortedFiles[LoadOrdering.State].Add(fileInformation);
                    break;

                case ".CHT":
                    sortedFiles[LoadOrdering.Cheat].Add(fileInformation);
                    break;

                case ".WCH":
                    sortedFiles[LoadOrdering.Watch].Add(fileInformation);
                    break;

                case ".CDL":
                    sortedFiles[LoadOrdering.CdFile].Add(fileInformation);
                    break;

                default:
                    if (MovieService.IsValidMovieExtension(ext))
                    {
                        sortedFiles[LoadOrdering.MovieFile].Add(fileInformation);
                    }
                    else if (MovieImport.IsValidMovieExtension(ext))
                    {
                        sortedFiles[LoadOrdering.LegacyMovieFile].Add(fileInformation);
                    }
                    else if (KnownRomExtensions.Contains(ext))
                    {
                        if (string.IsNullOrEmpty(archive) || !_nonArchive.Contains(ext))
                        {
                            sortedFiles[LoadOrdering.Rom].Add(fileInformation);
                        }
                    }
                    else
                    {
                        /* Because the existing behaviour for archives is to try loading
                         * ROMs out of them, that is exactly what we are going to continue
                         * to do at present.  Ideally, the archive should be scanned and
                         * relevant files should be extracted, but see the note below for
                         * further details.
                         */
                        var archiveHandler = new SharpCompressArchiveHandler();

                        if (string.IsNullOrEmpty(archive) && archiveHandler.CheckSignature(file, out _, out _))
                        {
                            sortedFiles[LoadOrdering.Rom].Add(fileInformation);
                        }
                        else
                        {
                            // This is hack is to ensure that unrecognized files are treated like ROMs
                            sortedFiles[LoadOrdering.Rom].Add(fileInformation);
                        }

                        /*
                         * This is where handling archives would go.
                         * Right now, that's going to be a HUGE hassle, because of the problem with
                         * saving things into the archive (no) and with everything requiring filenames
                         * and not streams (also no), so for the purposes of making drag/drop more robust,
                         * I am not building this out just yet.
                         * -- Adam Michaud (Invariel)
                         *
                         * int offset = 0;
                         * bool executable = false;
                         * var archiveHandler = new SevenZipSharpArchiveHandler();
                         *
                         * // Not going to process nested archives at the moment.
                         * if (String.IsNullOrEmpty (archive) && archiveHandler.CheckSignature(file, out offset, out executable))
                         * {
                         *      List<string> fileNames = new List<string>();
                         *      var openedArchive = archiveHandler.Construct (file);
                         *
                         *      foreach (BizHawk.Common.HawkFileArchiveItem item in openedArchive.Scan ())
                         *              fileNames.Add(item.Name);
                         *
                         *      ProcessFileList(fileNames.ToArray(), ref sortedFiles, file);
                         *
                         *      openedArchive.Dispose();
                         * }
                         * archiveHandler.Dispose();
                         */
                    }
                    break;
                }
            }
        }
コード例 #4
0
        private IEnumerable <Task <TaskResult <string> > > UploadMovieImage(MovieImport movieImport,
                                                                            Movie movie,
                                                                            GenerateDataContext context)
        {
            var uploadTasks = new List <Task <TaskResult <string> > >();

            if (string.IsNullOrWhiteSpace(movie.PosterImageUrl) && !string.IsNullOrWhiteSpace(movieImport.PosterImageFileName))
            {
                uploadTasks.Add(UploadImage(movie.Id,
                                            "Posters",
                                            movieImport.PosterImageFileName,
                                            (imageUrl, m) => m.PosterImageUrl = imageUrl,
                                            context));
            }

            if (string.IsNullOrWhiteSpace(movie.PosterTitleImageUrl) && !string.IsNullOrWhiteSpace(movieImport.PosterTitleImageFileName))
            {
                uploadTasks.Add(UploadImage(movie.Id,
                                            "PosterTitles",
                                            movieImport.PosterTitleImageFileName,
                                            (imageUrl, m) => m.PosterTitleImageUrl = imageUrl,
                                            context));
            }

            if (string.IsNullOrWhiteSpace(movie.ThumbnailImageUrl) && !string.IsNullOrWhiteSpace(movieImport.ThumbnailImageFileName))
            {
                uploadTasks.Add(UploadImage(movie.Id,
                                            "Thumbnails",
                                            movieImport.ThumbnailImageFileName,
                                            (imageUrl, m) => m.ThumbnailImageUrl = imageUrl,
                                            context));
            }

            if (string.IsNullOrWhiteSpace(movie.TallThumbnailImageUrl) && !string.IsNullOrWhiteSpace(movieImport.TallThumbnailFileName))
            {
                uploadTasks.Add(UploadImage(movie.Id,
                                            "TallThumbnails",
                                            movieImport.TallThumbnailFileName,
                                            (imageUrl, m) => m.TallThumbnailImageUrl = imageUrl,
                                            context));
            }

            if (string.IsNullOrWhiteSpace(movie.BillboardPosterImageUrl) && !string.IsNullOrWhiteSpace(movieImport.BillboardPosterImageFileName))
            {
                uploadTasks.Add(UploadImage(movie.Id,
                                            "BillboardPosters",
                                            movieImport.BillboardPosterImageFileName,
                                            (imageUrl, m) => m.BillboardPosterImageUrl = imageUrl,
                                            context));
            }

            if (string.IsNullOrWhiteSpace(movie.BillboardPosterTitleImageUrl) && !string.IsNullOrWhiteSpace(movieImport.BillboardPosterTitleImageFileName))
            {
                uploadTasks.Add(UploadImage(movie.Id,
                                            "BillboardPosterTitles",
                                            movieImport.BillboardPosterTitleImageFileName,
                                            (imageUrl, m) => m.BillboardPosterTitleImageUrl = imageUrl,
                                            context));
            }

            return(uploadTasks);
        }
コード例 #5
0
        private async Task <TaskResult <bool> > UploadMovieTrailerAsync(GenerateDataContext context, ObjectId movieId, MovieImport movieImport)
        {
            Console.WriteLine($"Uploading movie trailer {movieId}");

            var mediaName = $"trailer-{movieId}";
            TaskResult <bool> taskResult = new()
            {
                TaskName = mediaName
            };

            if (await CheckIfTrailerAlreadyExistsAsync(movieId))
            {
                Console.WriteLine($"Movie trailer for {movieId} has already been uploaded");
                taskResult.IsSuccessful = true;
                return(taskResult);
            }

            try
            {
                var trailFilePath = Path.Combine(context.ImportRootDir, "Trailers", movieImport.TrailerFileName);
                var streamingUrls = await _mediaService.EncodeVideoForStreaming(trailFilePath, mediaName);

                using var realm = await _realmFactory.GetDefaultSyncedRealmAsync();

                await realm.WriteAsync(r =>
                {
                    var movie          = r.Find <Movie>(movieId);
                    movie.StreamingUrl = streamingUrls.First(url => url.Contains("m3u8-aapl"));
                });

                taskResult.IsSuccessful = true;
                taskResult.Result       = true;
                Console.WriteLine($"Successfully uploaded movie trailer for {movieId}");
            }
            catch (Exception ex)
            {
                taskResult.IsSuccessful = false;
                taskResult.Error        = ex;
            }

            return(taskResult);
        }