Subject: Re: Megatools link format changed
From: Ondřej Jirman
Date: Tue, 25 Aug 2020 03:36:23 +0200
Hi,

On Mon, Aug 24, 2020 at 09:05:44PM -0400, Max Turgor wrote:
> Hi,
> 
> Thanks for creating megatools! I wanted to point out that the mega.nz link
> format appears to have changed again, causing the tool (v 1.11.0) to reject
> the links. (I think the links are just more characters now?) Here's a small
> example file:
> 
> *megadl
> https://mega.nz/file/rto3RJTb#qvkRM7D1tdrl-R4-b0hcQVwj3FvLOpRL6wEFr8nMjF4
> <https://mega.nz/file/rto3RJTb#qvkRM7D1tdrl-R4-b0hcQVwj3FvLOpRL6wEFr8nMjF4>*
> WARNING: Skipping invalid Mega download link:
> https://mega.nz/file/rto3RJTb#qvkRM7D1tdrl-R4-b0hcQVwj3FvLOpRL6wEFr8nMjF4
> 
> The same appears to be an issue with folders.
> 
> *megadl https://mega.nz/folder/Op43xICA#EOCBiRQsgc-An93XW6bkCA
> <https://mega.nz/folder/Op43xICA#EOCBiRQsgc-An93XW6bkCA>*
> WARNING: Skipping invalid Mega download link:
> https://mega.nz/folder/Op43xICA#EOCBiRQsgc-An93XW6bkCA
> 
> Since the format of the link appears to change somewhat regularly, I wonder
> if it would make sense to either skip link validation, or provide a
> --skip-validation option to allow a forced bypass of the validation step in
> case the format changes again.

It's not that simple. It's not like megatools just passes a link to mega
and magically gets the file data back. Link format needs to be understood,
parsed for the folder handle/encrpytion keys and whatever else they decided
to stuff in there this time, and that's just the beginning...

I don't have much interest in extending megatools, anymore, myself.
I just maintain the web, provide builds, and accept patches from time
to time.

Luckily the last time the format was changed, I made the code more generic,
so adding support for new format should be straightforward, unless they
changed the semantics of the link data. It would just involve adding
a few lines to this table:

https://megous.com/git/megatools/tree/tools/dl.c#n337

So if you figure out what part of the link is key and what is file handle,
I'll add it there. Anyway, looking at the new links, there's something not
quite right about the key part. File key should be 43 chars, folder key 22
chars, and that doesn't seem to be the case with the links you posted.

regards,
	o.

> Thanks for maintaining such a great tool!
>  -M