{"id":13858665,"url":"https://github.com/topac/rmega","last_synced_at":"2025-04-05T05:06:04.731Z","repository":{"id":7123577,"uuid":"8418409","full_name":"topac/rmega","owner":"topac","description":"mega.nz ruby API and command-line tool","archived":false,"fork":false,"pushed_at":"2023-05-16T06:44:16.000Z","size":222,"stargazers_count":147,"open_issues_count":0,"forks_count":31,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-29T04:06:47.083Z","etag":null,"topics":["api","downloader","kim-dotcom","mega","megadrive","megaupload","ruby","uploader"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/topac.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-25T21:15:33.000Z","updated_at":"2024-12-31T08:54:18.000Z","dependencies_parsed_at":"2024-06-19T01:39:57.702Z","dependency_job_id":"589201f8-0f4b-4d50-bdf9-126e423a71e4","html_url":"https://github.com/topac/rmega","commit_stats":{"total_commits":215,"total_committers":5,"mean_commits":43.0,"dds":"0.018604651162790753","last_synced_commit":"3c57574bd78d2271408aabfdfff9b5bfb1e07d8f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topac%2Frmega","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topac%2Frmega/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topac%2Frmega/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topac%2Frmega/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/topac","download_url":"https://codeload.github.com/topac/rmega/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289426,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","downloader","kim-dotcom","mega","megadrive","megaupload","ruby","uploader"],"created_at":"2024-08-05T03:02:16.773Z","updated_at":"2025-04-05T05:06:04.715Z","avatar_url":"https://github.com/topac.png","language":"Ruby","readme":"[![Gem Version](https://badge.fury.io/rb/rmega.svg)](https://badge.fury.io/rb/rmega)\n[![rmega](https://circleci.com/gh/topac/rmega.svg?style=svg)](https://circleci.com/gh/topac/rmega)\n\n\n# rmega\n\nPure ruby library for \u003cimg src=\"https://mega.co.nz/favicon.ico\" alt=\"\"/\u003e **MEGA** [https://mega.nz/](https://mega.nz/).  \nWorks on Linux and OSX with Ruby 2.1+.\n\n## Installation\n\n```\n  gem install rmega\n```\n\n## Command Line Usage\n\n\u003cimg src=\"https://i.imgur.com/3cjgp4g.gif\"/\u003e\n\nSince version 0.2.0 you can use the commands `rmega-dl` and `rmega-up` to download and upload files to MEGA.\n\n * Downloads are resumable\n * You can download all the links in a given file, e.g. `rmega-dl my_links.txt`\n * Scrape a web page and download all the MEGA links, e.g. `rmega-dl https://www.reddit.com/r/megalinks/foobar`\n * HTTP proxy support\n * Streaming! :beer: You can use a video player (VLC works perfectly) to play videos while downloading them\n * You can use it combined with [torsocks](https://github.com/dgoulet/torsocks/) to download and upload files through the Tor network (slower)\n\n## DSL Usage\n\n### Login\n\n```ruby\nrequire \"rmega\"\nstorage = Rmega.login(\"your@email.com\", \"your_password\")\n```\n\n### Browsing\n\n```ruby\n# Print the name of the files in the root folder\nstorage.root.files.each { |file| puts file.name }\n\n# Print the number of files in each folder\nstorage.root.folders.each do |folder|\n  puts \"Folder #{folder.name} contains #{folder.files.size} files.\"\nend\n\n# Print the name and the size of the files in the recyble bin\nstorage.trash.files.each { |file| puts \"#{file.name} of #{file.size} bytes\" }\n\n# Print the name of all the files (everywhere)\nstorage.nodes.each do |node|\n  next unless node.type == :file\n  puts node.name\nend\n\n# Print all the nodes (files, folders, etc.) within a spefic folder\nfolder = storage.root.folders[12]\nfolder.children.each do |node|\n  puts \"Node #{node.name} (#{node.type})\"\nend\n```\n\n### Searching\n\n```ruby\n# Search for a file within a specific folder\nfolder = storage.root.folders[2]\nfolder.files.find { |file| file.name == \"to_find.txt\" }\n\n# Search for a file everywhere\nstorage.nodes.find { |node| node.type == :file and node.name =~ /my_file/i }\n\n# Note: A node can be of type :file, :folder, :root, :inbox and :trash\n```\n\n### Download\n\n```ruby\n# Download a single file\nfile = storage.root.files.first\nfile.download(\"~/Downloads\")\n# =\u003e Download in progress 15.0MB of 15.0MB (100.0%)\n\n# Download a folder and all its content recursively\nfolder = storage.nodes.find do |node|\n  node.type == :folder and node.name == 'my_folder'\nend\nfolder.download(\"~/Downloads/my_folder\")\n\n# Download a file by url\npublic_url = 'https://mega.nz/file/MAkg2Iab#bc9Y2U6d93IlRRKVYpcC9hLZjS4G278OPdH6nTFPDNQ'\nRmega.download(public_url, '~/Downloads')\n```\n\n### Upload a file\n\n```ruby\n# Upload a file to a specific folder\nfolder = storage.root.folders[3]\nfolder.upload(\"~/Downloads/my_file.txt\")\n\n# Upload a file to the root folder\nstorage.root.upload(\"~/Downloads/my_other_file.txt\")\n```\n\n### Upload a directory\n\n```ruby\n# Upload a directory to a specific folder\nfolder = storage.root.folders[3]\nfolder.upload_dir(\"~/Downloads/my_directory\")\n\n# Upload a directory to the root folder\nstorage.root.upload_dir(\"~/Downloads/my_other_directory\")\n```\n\n### Creating a folder\n\n```ruby\n# Create a subfolder of the root folder\nnew_folder = storage.root.create_folder(\"my_documents\")\n\n# Create a subfolder of an existing folder\nfolder = storage.nodes.find do |node|\n  node.type == :folder and node.name == 'my_folder'\nend\nfolder.create_folder(\"my_documents\")\n```\n\n### Deleting\n\n```ruby\n# Delete a folder\nfolder = storage.root.folders[4]\nfolder.delete\n\n# Move a folder to the recyle bin\nfolder = storage.root.folders[4]\nfolder.trash\n\n# Delete a file\nfile = storage.root.folders[3].files.find { |f| f.name =~ /document1/ }\nfile.delete\n\n# Move a file to the recyle bin\nfile = storage.root.files.last\nfile.trash\n\n# Empty the trash\nunless storage.trash.empty?\n  storage.trash.empty!\nend\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopac%2Frmega","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftopac%2Frmega","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopac%2Frmega/lists"}