예제 #1
0
        public async Task <AccountProfile> GetFreeProfile(DownloadItem item)
        {
            List <AccountModel> profiles = _context.Accounts.ToList();

            foreach (AccountModel acc in profiles)
            {
                if (_profiles.ContainsKey(acc.ID))
                {
                    continue;
                }
                AccountProfile p          = new AccountProfile(acc);
                IDownloader    downloader = DownloadHelper.GetDownloader(p);
                if (downloader == null)
                {
                    continue;
                }
                p = await downloader.DoLogin(p);

                _profiles.Add(acc.ID, p);
            }

            AccountProfile profile = null;

            try
            {
                profile = _profiles.First(kv => kv.Value.Model.Hoster == item.Hoster && kv.Value.Model.IsPremium == true && kv.Value.Model.TrafficLeft > 1 && kv.Value.Model.TrafficLeftWeek > 1).Value;
            }
            catch { }

            return(profile);
        }
예제 #2
0
        public async Task <AccountProfile> GetProfile(AccountModel acc)
        {
            if (!_profiles.ContainsKey(acc.ID))
            {
                if (!_context.Accounts.Any(a => a.ID == acc.ID))
                {
                    return(null);
                }
                AccountProfile profile    = new AccountProfile(acc);
                IDownloader    downloader = DownloadHelper.GetDownloader(profile);
                if (downloader == null)
                {
                    return(null);
                }
                profile = await downloader.DoLogin(profile);

                _profiles.Add(acc.ID, profile);
            }

            return(_profiles[acc.ID]);
        }
예제 #3
0
        public static IDownloader GetDownloader(AccountProfile profile)
        {
            if (profile == null)
            {
                return(null);
            }
            IDownloader downloader = null;

            var q = from t in Assembly.GetExecutingAssembly().GetTypes()
                    where t.IsClass && t.IsNested == false && t.Namespace == "ShareLoader.Downloader"
                    select t;

            foreach (Type t in q.ToList())
            {
                IDownloader down = (IDownloader)Activator.CreateInstance(t);
                if (profile.Model.Hoster == down.Identifier)
                {
                    downloader = down;
                    break;
                }
            }

            return(downloader);
        }