Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mega.nz support #2286

Open
aaronsace opened this issue Jan 7, 2019 · 3 comments
Open

Add mega.nz support #2286

aaronsace opened this issue Jan 7, 2019 · 3 comments
Assignees

Comments

@aaronsace
Copy link
Member

#To-do: add support for 'https://mega.nz'

Written in C#; looks hopefull:
https://github.com/gpailler/MegaApiClient

@aaronsace aaronsace self-assigned this Jan 7, 2019
@skovesh
Copy link

skovesh commented Jan 12, 2019

specific instructions on how to implement the enhancement might help me nd other "normal" miners, thank you very much. I read the docs, but still didn't succeed to get it run :(

@aaronsace
Copy link
Member Author

@skovesh I think you've misunderstood the issues section on Github. The releases are published here: https://github.com/MultiPoolMiner/MultiPoolMiner/releases

@MaynardMiner
Copy link

MaynardMiner commented Sep 24, 2020

I wrote out a powershell translation. Thought I would share as this issue was inspiration.

Use this nuget package (.dll):

https://www.nuget.org/packages/MegaApiClient/

extract .dll with 7z

Add-Type -Path "MegaApiClient.dll"

function Get-MegaDownload($link) {
    $id = [IO.Path]::GetFileName($link);
    $client = [CG.Web.MegaApiClient.MegaApiClient]::New();
    $client.LoginAnonymous();
    [uri]$uri = [uri]::New($link);
    [System.Collections.Generic.IEnumerable[CG.Web.MegaApiClient.INode]]$nodes = $client.GetNodesFromLink($uri);
    $node = $nodes | Where-Object id -eq $id;
    ## Determine full path to download file
    $Path = [IO.Path]::Combine([IO.Path]::Combine($global:Dir, "x64"), $node.Name);
    if ([IO.File]::Exists($Path)) {
        Remove-Item -Path $Path -Force
    }
    Using-Object ($stream = $client.Download($node)) {
        Using-Object ($filestream = [System.IO.FileStream]::New($Path, [System.IO.FileMode]::CreateNew)) {
            $stream.CopyTo($filestream);
        }
    }
    $client.Logout();
    ## Return path for reference and folder name, since we didn't know it based on link.
    return $Path;
}

Requires the ability to run C# using statement. Below is an example:

function Using-Object
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [AllowEmptyString()]
        [AllowEmptyCollection()]
        [AllowNull()]
        [Object]
        $InputObject,

        [Parameter(Mandatory = $true)]
        [scriptblock]
        $ScriptBlock
    )

    try
    {
        . $ScriptBlock
    }
    finally
    {
        if ($null -ne $InputObject -and $InputObject -is [System.IDisposable])
        {
            $InputObject.Dispose()
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants