Beispiel #1
0
        private void downloadFiles()
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            textBox1.Text = textBox1.Text + "\r\ndownloading the latest version...";
            MegaApiClient mega = new MegaApiClient();

            mega.LoginAnonymous();
            Uri link = new Uri(megaLink);
            IEnumerable <INode> nodes = mega.GetNodesFromLink(link);

            foreach (INode node in nodes.Where(x => x.Type == NodeType.File))
            {
                if (node.ParentId == "OG4B2D6S" || node.ParentId == "KSpkxCwB" || File.Exists(Path.Combine(path, node.Name)))
                {
                    continue;
                }
                mega.DownloadFile(node, Path.Combine(path, node.Name));
                textBox1.Text = textBox1.Text + ".";
            }

            mega.Logout();
            textBox1.Text = textBox1.Text + "\r\nfinished downloading";
        }
Beispiel #2
0
        async void Button3Click(object sender, EventArgs e)
        {
            ListViewItem lvitem = null;

            try
            {
                lvitem = listView1.Items[listView1.SelectedIndices[0]];
            }
            catch
            {
                return;
            }
            if (lvitem == null)
            {
                return;
            }
            try
            {
                label1.Text = "Downloading...";
                SaveFileDialog sfd = new SaveFileDialog();
                DialogResult   dr  = sfd.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    string fp = sfd.FileName;
                    await Task.Run(() => mclient.DownloadFile(nodeDict[lvitem.Text], fp));
                }
                label1.Text = "Downloaded Successfully.";
            }
            catch (Exception ex)
            {
                label1.Text = "Download Error.";
                MessageBox.Show("An error occurred downloading the file.");
            }
        }
Beispiel #3
0
        private string DownloadArchive(IGroup group)
        {
            ReportProgress(SyncStage.DownloadingArchive, group);
            INode archiveNode = nodes
                                .SingleOrDefault(n => n.Name == group.Name + archiveFileNameSuffix && n.Type == NodeType.File && n.ParentId == archivesFolderNode.Id);
            string archive = Path.Combine(tempArchivesFolderPath, group.Name);

            client.DownloadFile(archiveNode, archive + archiveFileNameSuffix);
            return(archive);
        }
            public override async Task Download(Archive a, string destination)
            {
                var client = new MegaApiClient();

                Utils.Status("Logging into MEGA (as anonymous)");
                client.LoginAnonymous();
                var fileLink = new Uri(Url);
                var node     = client.GetNodeFromLink(fileLink);

                Utils.Status($"Downloading MEGA file: {a.Name}");
                client.DownloadFile(fileLink, destination);
            }
Beispiel #5
0
        public void DownloadFileFromUrl(string url)
        {
            var client = new MegaApiClient();

            client.LoginAnonymous();

            Uri       fileLink = new Uri("https://mega.nz/#!bkwkHC7D!AWJuto8_fhleAI2WG0RvACtKkL_s9tAtvBXXDUp2bQk");
            INodeInfo node     = client.GetNodeFromLink(fileLink);

            Console.WriteLine($"Downloading {node.Name}");
            client.DownloadFile(fileLink, node.Name);

            client.Logout();
        }
Beispiel #6
0
        public Task DownloadFiles()
        {
            var nodes = _service.GetNodes();

            foreach (var node in nodes)
            {
                if (node.Type == NodeType.File)
                {
                    _service.DownloadFile(node, node.Name);
                }
            }

            Console.WriteLine("Done downloading");
            return(Task.FromResult(0));
        }
Beispiel #7
0
        private bool DownloadMegaArchive(MEGAArchive m, bool download)
        {
            var client = new MegaApiClient();

            Status("Logging into MEGA (as anonymous)");
            client.LoginAnonymous();
            var file_link = new Uri(m.URL);
            var node      = client.GetNodeFromLink(file_link);

            if (!download)
            {
                return(true);
            }
            Status("Downloading MEGA file: {0}", m.Name);

            var output_path = Path.Combine(DownloadFolder, m.Name);

            client.DownloadFile(file_link, output_path);
            return(true);
        }
        private bool ProcessDownloadMega(Comic comic)
        {
            try
            {
                Uri       uri      = new Uri(comic.Link);
                INodeInfo infoMega = ApiMega.GetNodeFromLink(uri);
                ApiMega.DownloadFile(uri, Environment.CurrentDirectory + Constantes.Download + infoMega.Name);
                comic.NameWeb = infoMega.Name;
                comic.SizeWeb = Functions.FormatSize(infoMega.Size);

                return(true);
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.Error(string.Format("Error en el método: '{0}', Mensaje de error: '{1}'", MethodBase.GetCurrentMethod().Name, ex.Message));
                }
                return(false);
            }
        }
Beispiel #9
0
        public void download_qr_codes(string linkki_u)
        {
            String linkki;

            linkki = linkki_u;


            var client = new MegaApiClient();

            client.Login("ADD_MEGA_USERNAME_HERE", "PASSWORD_HERE");

            Uri folderLink            = new Uri(linkki);
            IEnumerable <INode> nodes = client.GetNodesFromLink(folderLink);

            foreach (INode node in nodes.Where(x => x.Type == NodeType.File))
            {
                MessageBox.Show($"Downloading {node.Name}");
                client.DownloadFile(node, node.Name);
            }

            client.Logout();
        }
Beispiel #10
0
        public static void DownloadReferenceUrl(Launcher.Game game, bool clearCache = true)
        {
            string displayName;

            if (game.Name.Length > 0)
            {
                displayName = game.Name;
            }
            else
            {
                displayName = game.ID;
            }

            string workingDir = "";

            if (game.Root == "roms" || game.Root == "data")
            {
                workingDir = Path.Combine(Launcher.rootDir, "nulldc-1-0-4-en-win", game.Root);
            }
            else
            {
                Console.WriteLine("no valid root found in reference entry");
                return;
            }
            var di = new DirectoryInfo(workingDir);

            di.Attributes |= FileAttributes.Normal;
            var zipPath = Path.Combine(workingDir, $"{Path.GetFileNameWithoutExtension(game.ReferenceUrl)}.zip");

            if (!File.Exists(zipPath))
            {
                Console.WriteLine($"Downloading {displayName}...");
                var referenceUri = new Uri(game.ReferenceUrl);
                if (referenceUri.Host == "mega.nz")
                {
                    MegaApiClient client = new MegaApiClient();
                    client.LoginAnonymous();

                    INodeInfo node = client.GetNodeFromLink(referenceUri);

                    Console.WriteLine($"Downloading {node.Name}");
                    client.DownloadFile(referenceUri, zipPath);

                    client.Logout();
                }
                else
                {
                    using (WebClient client = new WebClient())
                    {
                        Console.WriteLine($"Downloading {Path.GetFileName(referenceUri.LocalPath)}");
                        client.DownloadFile(referenceUri,
                                            zipPath);
                    }
                }
                Console.WriteLine($"Download Complete");
            }

            Console.WriteLine($"Extracting...\n");

            string extractPath;

            if (game.Root == "roms")
            {
                extractPath = Path.Combine(workingDir, displayName);
                Directory.CreateDirectory(extractPath);
            }
            else
            {
                extractPath = workingDir;
            }

            using (ZipArchive archive = ZipFile.OpenRead(zipPath))
            {
                List <Launcher.Asset> files = game.Assets;
                foreach (ZipArchiveEntry entry in archive.Entries)
                {
                    try
                    {
                        var fileEntry = files.Where(f => f.Name == entry.Name).First();
                        if (fileEntry != null)
                        {
                            var destinationFile = Path.Combine(extractPath, fileEntry.LocalName());
                            entry.ExtractToFile(destinationFile, true);
                            Console.WriteLine(fileEntry.VerifyFile(destinationFile));
                        }
                    }
                    catch (Exception) { }
                }
            }

            if (clearCache)
            {
                File.Delete(zipPath);
            }

            Console.WriteLine($"\nPress any key to continue.");
            Console.ReadKey();
        }