Exemple #1
0
        private async Task cacheTicket(TitleInfo item)
        {
            if (item.hasTicket)
            {
                try
                {
                    string tikFilePath = Path.Combine(Common.TicketsPath, item.titleID + ".tik");
                    if (File.Exists(tikFilePath))
                    {
                        item.ticket = File.ReadAllBytes(tikFilePath);
                    }
                    else
                    {
                        byte[] ticket = await HelperFunctions.DownloadTitleKeyWebsiteTicket(item.titleID);

                        File.WriteAllBytes(tikFilePath, ticket);
                        item.ticket = ticket;
                    }
                }
                catch { }
            }
        }
        private Nullable <DownloadItem> getDownloadItem(TitleInfo item, DownloadType type)
        {
            TitleInfo info;

            lock (item)
            {
                info = item;
            }

            switch (type)
            {
            case DownloadType.Game:
                if (!info.isUpdate)
                {
                    try
                    {
                        bool madeTicket = false;
                        TMD  titleTMD   = AsyncHelpers.RunSync <TMD>(() => NUS.DownloadTMD(info.titleID));

                        if (info.ticket.Length == 0 && info.hasTicket)
                        {
                            info.ticket = AsyncHelpers.RunSync <byte[]>(() => HelperFunctions.DownloadTitleKeyWebsiteTicket(info.titleID));
                        }


                        if (!info.hasTicket && info.titleKey.Length > 0)
                        {
                            madeTicket  = true;
                            info.ticket = info.getGeneratedTitleTicket(titleTMD.TitleVersion);
                        }

                        return(new DownloadItem(
                                   info.displayName + (madeTicket ? " (FakeSign)" : ""),
                                   titleTMD,
                                   AsyncHelpers.RunSync <NUS.UrlFilenamePair[]>(() => NUS.GetTitleContentURLs(titleTMD, true)),
                                   info.ticket,
                                   null,
                                   null,
                                   madeTicket
                                   ));
                    }
                    catch { }
                }
                break;

            case DownloadType.DLC:
                try
                {
                    if (info.dlcKey.Length > 0)
                    {
                        TMD dlcTMD = AsyncHelpers.RunSync <TMD>(() => NUS.DownloadTMD(info.dlcID));

                        return(new DownloadItem(
                                   info.DisplayNameWithVersion(dlcTMD.TitleVersion, "DLC") + " (FakeSign)",
                                   dlcTMD,
                                   AsyncHelpers.RunSync <NUS.UrlFilenamePair[]>(() => NUS.GetTitleContentURLs(dlcTMD, true)),
                                   info.getDLCTicket(dlcTMD.TitleVersion),
                                   null,
                                   null,
                                   true
                                   ));
                    }
                }
                catch { }
                break;

            case DownloadType.Update:
                try
                {
                    TMD updateTMD = AsyncHelpers.RunSync <TMD>(() => NUS.DownloadTMD(info.updateID));
                    return(new DownloadItem(
                               info.DisplayNameWithVersion(updateTMD.TitleVersion, "Update"),
                               updateTMD,
                               AsyncHelpers.RunSync <NUS.UrlFilenamePair[]>(() => NUS.GetTitleContentURLs(updateTMD, true)),
                               AsyncHelpers.RunSync <byte[]>(() => NUS.DownloadTicket(info.updateID))
                               ));
                }
                catch { }
                break;
            }
            return(null);
        }