From: Alberto Garcia Subject: Support new format of mega.nz links Origin: https://megous.com/git/megatools/commit/?id=5d04a6203a231e8a3ea19bd1f203faee88e4b3a9 Index: megatools/tools/dl.c =================================================================== --- megatools.orig/tools/dl.c +++ megatools/tools/dl.c @@ -145,6 +145,7 @@ int main(int ac, char* av[]) { gc_error_free GError *local_err = NULL; gc_regex_unref GRegex *file_regex = NULL, *folder_regex = NULL; + gc_regex_unref GRegex *file_regex2 = NULL, *folder_regex2 = NULL;; gint i; int status = 0; @@ -179,9 +180,15 @@ int main(int ac, char* av[]) file_regex = g_regex_new("^https?://mega(?:\\.co)?\\.nz/#!([a-z0-9_-]{8})!([a-z0-9_-]{43})$", G_REGEX_CASELESS, 0, NULL); g_assert(file_regex != NULL); + file_regex2 = g_regex_new("^https?://mega\\.nz/file/([a-z0-9_-]{8})#([a-z0-9_-]{43})$", G_REGEX_CASELESS, 0, NULL); + g_assert(file_regex2 != NULL); + folder_regex = g_regex_new("^https?://mega(?:\\.co)?\\.nz/#F!([a-z0-9_-]{8})!([a-z0-9_-]{22})$", G_REGEX_CASELESS, 0, NULL); g_assert(folder_regex != NULL); + folder_regex2 = g_regex_new("^https?://mega\\.nz/folder/([a-z0-9_-]{8})#([a-z0-9_-]{22})$", G_REGEX_CASELESS, 0, NULL); + g_assert(folder_regex2 != NULL); + // create session s = tool_start_session(0); @@ -197,7 +204,7 @@ int main(int ac, char* av[]) gc_free gchar* handle = NULL; gc_free gchar* link = tool_convert_filename(av[i], FALSE); - if (g_regex_match(file_regex, link, 0, &m1)) + if (g_regex_match(file_regex, link, 0, &m1) || g_regex_match(file_regex2, link, 0, &m1)) { handle = g_match_info_fetch(m1, 1); key = g_match_info_fetch(m1, 2); @@ -219,7 +226,7 @@ int main(int ac, char* av[]) g_print("%s\n", cur_file); } } - else if (g_regex_match(folder_regex, link, 0, &m2)) + else if (g_regex_match(folder_regex, link, 0, &m2) || g_regex_match(folder_regex2, link, 0, &m2)) { if (opt_stream) {