Beispiel #1
0
            public override bool AssociateMetaData()
            {
                if (metaData != null)
                {
                    return(true);
                }
                if (Matches == null || Matches.Length == 0)
                {
                    return(false);
                }
                GD3DVD.DVDMatch match   = Matches[SelectedMatch ?? 0];
                var             dvdCode = match.DVDCode;
                var             discID  = match.DiscID;
                var             t       = Tuple.Create(dvdCode, discID);

                return(metaDataGD3.dvdCodeDiscIDToMetaData.TryGetValue(t, out metaData));
            }
Beispiel #2
0
            public async Task <bool> RetrieveMetaData(MetaDataGD3 metaDataGD3, string path)
            {
                if (Matches == null || Matches.Length == 0 || metaData != null)
                {
                    return(false);
                }
                GD3DVD.DVDMatch match   = Matches[SelectedMatch ?? 0];
                var             dvdCode = match.DVDCode;
                var             discID  = match.DiscID;
                var             t       = Tuple.Create(dvdCode, discID);

                if (AssociateMetaData())
                {
                    return(false);
                }
                var task = metaDataGD3.SoapClientDVD.RetrieveDVDMetaByDiscIDAsync(metaDataGD3.authDVD, dvdCode, discID);

                if (await Task.WhenAny(task, Task.Delay(30000)) != task)
                {
                    throw new Exception("GD3DVD RetrieveDVDMetaByDiscIDAsync timeout: " + dvdCode);
                }
                var retrieveDVDMetaResponse = await task;
                var dvdMeta = retrieveDVDMetaResponse?.RetrieveDVDMetaByDiscIDResult;

                if (dvdMeta == null)
                {
                    return(false);
                }
                string title                   = MetaDataProvider.RemoveBlacklistedCharacters(GetTitlePlusDisc(dvdMeta) ?? "NoTitle", 80);
                string fileNameBase            = $"Meta_{match.MediaType}_{title}_{dvdCode}_{discID}";
                string frontCoverImageFileName = null;
                string backCoverImageFileName  = null;
                var    ai = dvdMeta.FrontCover;
                var    bc = dvdMeta.BackCover;

                if (ai != null)
                {
                    if (ai.Length > 0)
                    {
                        frontCoverImageFileName = await WriteImage(ai, path, $"MetaFrontCover_{title}_{dvdCode}");
                    }
                    dvdMeta.FrontCover = null;
                }
                if (bc != null)
                {
                    if (bc.Length > 0)
                    {
                        backCoverImageFileName = await WriteImage(bc, path, $"MetaBackCover_{title}_{dvdCode}");
                    }
                    dvdMeta.BackCover = null;
                }
                var m = new MetaDataDVD
                {
                    DVDCode       = dvdCode,
                    DiscID        = discID,
                    DVDMeta       = dvdMeta,
                    ImageFileName = frontCoverImageFileName ?? backCoverImageFileName
                };

                using (var f = File.Create(Path.Combine(path, Path.ChangeExtension(fileNameBase, "json"))))
                {
                    var w = new Utf8JsonWriter(f, new JsonWriterOptions {
                        Indented = true
                    });
                    JsonSerializer.Serialize(w, m);
                    f.Close();
                }
                metaDataGD3.dvdCodeDiscIDToMetaData[t] = m;
                metaData = m;
                return(true);
            }