static Plugin() { //todo: replace with MegaUrlDataExtractor _newFormatRegex = new Regex(@"/(?<type>(file|folder))/(?<id>[^#/ ]+)(#(?<key>[a-zA-Z0-9_-]+))?");//Regex("(#F|#)![a-zA-Z0-9]{0,8}![a-zA-Z0-9_-]+"); _oldFormatRegex = new Regex("#(?<type>F?)!(?<id>[^!]+)(!(?<key>[^$!\\?<'\"\\s]+))?"); string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mega_credentials.json"); IConfiguration configuration = new ConfigurationBuilder() .AddJsonFile(configPath, true, false) .Build(); if (!File.Exists(configPath)) { LogManager.GetCurrentClassLogger().Warn("!!!![MEGA]: mega_credentials.json not found, mega downloading will be limited! Refer to documentation for additional information. !!!!"); } else { _megaCredentials = new MegaCredentials(configuration["email"], configuration["password"]); } try { _megaDownloader = new MegaDownloader(_megaCredentials); } catch (Exception ex) { LogManager.GetCurrentClassLogger().Fatal("!!!![MEGA]: Unable to initialize mega downloader, check email and password! No mega files will be downloaded in this session. !!!!"); } }
private readonly int _maxRetries = 10; //todo: load from IUniversalDownloaderPlatformSettings public MegaDownloader(MegaCredentials credentials = null) { _client = new MegaApiClient(); if (credentials != null) { _client.Login(credentials.Email, credentials.Password); } else { _client.LoginAnonymous(); } }