GithubHelp home page GithubHelp logo

topac / rmega Goto Github PK

View Code? Open in Web Editor NEW
145.0 18.0 32.0 222 KB

mega.nz ruby API and command-line tool

License: MIT License

Ruby 99.71% Dockerfile 0.29%
ruby mega downloader uploader api kim-dotcom megaupload megadrive

rmega's People

Contributors

alex-taffe avatar grosa1 avatar guiceolin avatar microweb10 avatar topac avatar yasuoza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rmega's Issues

How to do storage

Im a total noob with ruby, can you tell me how to do the DSL thing? I just want to store my account. Thanks

Retry attempts

I noticed rmega doesn't have a retry attempt feature. Any network interruption causes download to stop.
I'm on one of the worst networks on earth, and any network-related interruptions causes the the error: ERROR: Unexpected data length to be thrown.

A way to specify retry attempts will be priceless, and I'll be the first to set mine at 2M retries!

Excessively slow aes_cbc_mac function

This function is very slow and uses excessive amounts of CPU:

def aes_cbc_mac(key, data, iv)
cipher = aes_cbc_cipher
cipher.encrypt
cipher.padding = 0
cipher.iv = iv if iv
cipher.key = key
n = 0
mac = nil
loop do
block = data[n..n+15]
break if !block or block.empty?
block << "\x0"*(16-block.size) if block.size < 16
n += 16
mac = cipher.update(block)
end
return mac
end

This is a pragmatic issue for me. I've been downloading a ~50G directory over several invocations, and each time I start rmega-dl, it takes a long time to verify the already-downloaded portion and makes my fan turn on. As the function is currently implemented, it only verifies about 30M per second.

The issue appears to be the fact that it processes the data 16 bytes at a time. This probably makes sense in a language like C, but in Ruby, a tight loop like this has a ton of overhead. I tried modifying this function to pass the data in all at once and then just extract the last 16 bytes, and not only did it approximately triple the speed of verification, it also didn't make my fan turn on. I don't think the specific modification I made is necessarily the best solution, but it does prove that the current one is suboptimal.

Raise error when try to read name of shared nodes

After v0.1.6 it is possible to read name of files that shared from others to you.

But it is still not possible to decrypt the name of nodes that shared by you to other guys. (for public and private shares)

Object (typically, node or user) not found (Rmega::RequestError)

storage = Rmega.login('[email protected]', 'xxx')

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rmega-0.1.2/lib/rmega/session.rb:61:in 'request': Error -9: Object (typically, node or user) not found (Rmega::RequestError)         from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rmega-0.1.2/lib/rmega/session.rb:35:in 'login'         from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rmega-0.1.2/lib/rmega/session.rb:20:in 'initialize'         from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rmega-0.1.2/lib/rmega/session.rb:8:in 'new'         from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rmega-0.1.2/lib/rmega/session.rb:8:in 'login'         from C:/Users/xxx/Desktop/xxx.rb:2:in '<main>'
ruby 2.0.0p247 (x64-mingw32)
latest rmega

ERROR: `read_configuration_file': undefined method `exists?' for File:Class (NoMethodError)`

Hello, I'm trying to upload file. And I have issue with "exists?"

nikita@nikita-desktop:~/LineageOS> rmega-up.ruby3.2 out/target/product/j4lte/lineage-17.1-20230514-UNOFFICIAL-j4lte.zip -u [email protected]
/usr/lib64/ruby/gems/3.2.0/gems/rmega-0.3.1/lib/rmega/cli.rb:30:in `read_configuration_file': undefined method `exists?' for File:Class (NoMethodError)

        return {} unless File.exists?(configuration_filepath)
                             ^^^^^^^^
Did you mean?  exist?
	from /usr/lib64/ruby/gems/3.2.0/gems/rmega-0.3.1/lib/rmega/cli.rb:9:in `cli_options'
	from /usr/lib64/ruby/gems/3.2.0/gems/rmega-0.3.1/bin/rmega-up:11:in `<top (required)>'
	from /usr/bin/rmega-up.ruby3.2:25:in `load'
	from /usr/bin/rmega-up.ruby3.2:25:in `<main>'

How to solve it?
Thank you.

NoMethodError: undefined method `root' for #<Rmega::Storage:0x007fc3da597310>

hello,
attempted some examples in the readme:

storage = Rmega.login('[email protected]', 'mypass')

storage.root.files.each { |file| puts file.name }
NoMethodError: undefined method `root' for #<Rmega::Storage:0x007fc3da597310>

storage.nodes
NoMethodError: undefined method `first' for -3:Fixnum
    from /Users/kain/.rvm/gems/ruby-2.1.1/gems/rmega-0.0.3/lib/rmega/session.rb:68:in `request'
    from /Users/kain/.rvm/gems/ruby-2.1.1/gems/rmega-0.0.3/lib/rmega/storage.rb:33:in `nodes'

[Feature Request] HTTP connection reuse

Currently, for every call to http_get_content() a new connection is created. this is slow. very slow. 10Mbps on a 200Mbps network slow.

This also eliminates HTTP/2's throughput benefits for small requests (such as API requests interleaved with data)

A solution would be to modify Rmega::Net to a more object-oriented approach (or at least offer it) such that at least each file operates over a single connection. Possibly even going as far as one connection per host per thread.

Link file handling

A feature request. (I will look into it if I learn ruby quickly)

When having a list with links it would be nice that rmega tags completed links so it doesn't use them again, same with those that are dead. (Use again happens when a error occur and you don't know what link it was working with)
This could also be used when scraping websites, store in a file, tag those completed or faulty.

undefined method `[]' for nil:NilClass

I'm testing the library in a threaded environment (sidekiq), I found an exception, will report more as I find them.

I'm not sure what caused this one, probably it's caused my multiple sessions being instanced between processes/threads.

WARN: undefined method `[]' for nil:NilClass
WARN: /Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/crypto/crypto.rb:34:in `block in decrypt_rsa_privk'
/Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/crypto/crypto.rb:33:in `times'
/Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/crypto/crypto.rb:33:in `decrypt_rsa_privk'
/Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/session.rb:44:in `login'
/Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/session.rb:21:in `initialize'
/Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/session.rb:8:in `new'
/Users/kain/.rvm/gems/ruby-2.1.2/bundler/gems/rmega-0839f38050a0/lib/rmega/session.rb:8:in `login'

ERROR: end of file reached, rmega-up command

I tried to use the "rmega-up" command to upload a test file called "a.pdf."
However, rmega keeps throwing up the error, "ERROR: end of file reached"
Here is the exact code I used:
"USER$ rmega-up a.pdf -u EMAIL_ID@gmail.com --pass"
(I also tried "a.pdf" with the quotes, didn't make a difference)
It logs into the account, and shows an initial upload phase where it says, "[Upload] 0.0 bytes of 737.46 kb, 0.0% @ 0.0 bytes/s, 4 threads", but then just throws up the error, "ERROR: end of file reached"

Kindly help me

Help with rmega-up command

Hello I would like to get some help
I never had contact Ruby, however I managed to install it in the 2.2.2 version on a VPS Centos 6.6 64bit.

The rmega-dl command worked perfectly.

However the rmega-up command returns me the following error:
Error: User email is required

Investigating a little more I noticed that one existed rmega_account.yml.example file.

I put my account details MEGA and rename it to rmega_account.yml.

Yet still get the error mentioned when I run rmega-up command

the I do to use only these two commands: download and upload files to the mega using ssh terminal?

Unable to allocate space for file

Error when running rmega-dl even as root to download to external drive

[Allocate] 0.0 bytes of 8.71 GB, 0.0% @ 0.0 bytes/s, 4 threadsTraceback (most recent call last):
9: from /usr/local/bin/rmega-dl:23:in <main>' 8: from /usr/local/bin/rmega-dl:23:in load'
7: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/bin/rmega-dl:32:in <top (required)>' 6: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/lib/rmega/cli.rb:113:in cli_rescue'
5: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/bin/rmega-dl:65:in block in <top (required)>' 4: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/bin/rmega-dl:65:in each_with_index'
3: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/bin/rmega-dl:65:in each' 2: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/bin/rmega-dl:68:in block (2 levels) in <top (required)>'
1: from /var/lib/gems/2.5.0/gems/rmega-0.2.4/lib/rmega/nodes/downloadable.rb:76:in download' /var/lib/gems/2.5.0/gems/rmega-0.2.4/lib/rmega/nodes/downloadable.rb:12:in allocate': Unable to allocate space for file /media/ubuntu/hdd1/InstallESD.iso (RuntimeError)

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

There is even a License Finder to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for missing ones as a public service :)
https://gist.github.com/bf4/5952053#file-license_issue-rb-L13 So far it's going pretty well

Support for PHP

Hi can you add code for download using PHP with resume support. There are codes already on github for mega download but none of them support resume.

Command issue

I manage to download files with "rmega-dl" but can't sign in and download them.

I get an error: ERROR: undefined method folders' for nil:NilClass`

I use the code:
rmega-dl 'https://mega.nz/#F!LS***' -o /downloads/Mega/ -u ***@163.com --pass ***

I get the code working without the signing in part.
Can't figure out whats wrong.

Error Message when Quota of Plan Exceeded is "ERROR: Unexpected Length"

using rmega-dl.

I encountered "ERROR: Unexpected Length". I figured it eventually out (Free Quote Exceeded), but the error message does not really indicated anything useful to the user.

Moreover, I have a pretty sizeable collection of links which is being downloaded - but as soons as one of the links does not work (after the 10 retries) (with the above mentioned error), rmega-dl stops. But links later in the list work - so, imo it would be much more useful to message the user that the download has failed, but then continue working on the rest of the list.

web gui request

hello, is there any possibility you can add a web ui so we can
use it from mobiles.

Checksum error

Noticed that sometimes rmega-dl gives a checksum error on a file, if I run the tool again it does not give a error. Using 4 threads. (Noticed that using more threads can cause this more often)
Know this is difficult to troubleshoot but just wanted to put it out here.

ERROR: File exists @ dir_s_mkdir

Got this message when downloading from a link with a couple of files and folders.
The root directory has a space in it's name, maybe that can be a reason? (The root name is from mega so I can't change it)

Link

You can add creation and removal of a link to file

caching / serialization impossible?

Hello,
is there a way to request a single file public url given a handle (or filename for instance) without listing nodes, folders, etc.?

I guess there is not, but consider a streaming endpoint, when a file gets requested in order to have a public_url I need to go through all nodes first in order to bring up a valid Node instance.

Probably there's no way around and I suspect that even a cache might not be a viable option due to all the session/crypto going around.

I'm caching the final public_url for at least 30 seconds to be resilient again multiple partial content requests, but what bothers me is that I need to query everything again for each new file:

    Rails.cache.fetch(media_file.cache_key, race_condition_ttl: 10, expires_in: 30.seconds) do
      service_response = trap_remote_call(:stream) do
        storage.nodes.lazy.select do |node|
          node.type == :file && node.name == media_file.remote_path # filename (not handle)
        end.to_a.first
      end
      service_response.public_url # this fires off a request(a: 'l', n: handle)

The upload target URL you are trying to access has expired. Please request a fresh one. (Rmega::ServerError)

If I just do

require 'rmega'
storage = Rmega.login('valid_username', 'valid_password')

I get:

Traceback (most recent call last):
	5: from rmega.rb:2:in `<main>'
	4: from /home/sourav/.gem/ruby/2.7.0/gems/rmega-0.2.6/lib/rmega.rb:34:in `login'
	3: from /home/sourav/.gem/ruby/2.7.0/gems/rmega-0.2.6/lib/rmega/session.rb:94:in `login'
	2: from /home/sourav/.gem/ruby/2.7.0/gems/rmega-0.2.6/lib/rmega/session.rb:144:in `request'
	1: from /home/sourav/.gem/ruby/2.7.0/gems/rmega-0.2.6/lib/rmega/net.rb:7:in `survive'
/home/sourav/.gem/ruby/2.7.0/gems/rmega-0.2.6/lib/rmega/session.rb:150:in `block in request': The upload target URL you are trying to access has expired. Please request a fresh one. (Rmega::ServerError)

I need help! How to solve this?

Error:
No such file or directory @ rb_file_s_size - C:/xampp/htdocs/descargas/file.rar

My code:
public_url = 'https://mega.nz/file/TctykRzL#p5xkGEjIz9VcegfbBh2maCD3JGKmsIdaOXahf_ZL-ZI' Rmega.download(public_url, Rails.root)

skip empty data

On some links people have uploaded file that are empty, for example some . files.
Is it possible to skip these empty files so the download can continue?

about app api keys and sessions

hello,
the mega documentation states that you need an api key to call the API, but this gem doesn't seem to provide a way to include it in requests; it's working though, so I don't understand if it's mandatory or not, do you have any more info about that?

about sessions: I saw other libraries (php, etc.) providing a way to represent and persist the session to be able to reconstruct it when needed. Do you have more information about mega sessions to share, how they roughly work, if they expire, etc.?

thanks

Server error on Login

require "rmega"
storage = Rmega.login("[email protected]", "your_password")

result

Rmega::ServerError: Object (typically, node or user) not found
    from /cache/gems/rmega-0.2.2/lib/rmega/session.rb:150:in `block in request'
    from /cache/gems/rmega-0.2.2/lib/rmega/net.rb:7:in `survive'
    from /cache/gems/rmega-0.2.2/lib/rmega/session.rb:144:in `request'
    from /cache/gems/rmega-0.2.2/lib/rmega/session.rb:94:in `login'
    from /cache/gems/rmega-0.2.2/lib/rmega.rb:33:in `login'
    from (irb):6
    from /cache/gems/railties-4.2.7/lib/rails/commands/console.rb:110:in `start'
    from /cache/gems/railties-4.2.7/lib/rails/commands/console.rb:9:in `start'
    from /cache/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /cache/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /cache/gems/railties-4.2.7/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.