Exemple #1
0
        public ThemeColorModel GetCachedTheme()
        {
            var model = _storageService.GetLocalSetting <ThemeColorModel>(nameof(ThemeColorModel));

            if (model == null)
            {
                _logService.Debug($"Didn't find the cached theme color");
            }
            else
            {
                _logService.Debug($"Cached theme color is {model.ThemeColor.ToString()}");
            }
            return(model);
        }
        public void ShowDownloadFinishedToast(string message)
        {
            var isToastOn = _storageService.GetLocalSetting <bool>(Definition.SETTING_TOAST);

            if (!isToastOn)
            {
                return;
            }
            try
            {
                string      basicNotification = "<toast><visual><binding template=\"ToastGeneric\"><text>下载完成</text><text>" + message + "</text></binding></visual></toast>";
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(basicNotification);
                ToastNotification notification = new ToastNotification(doc);
                _notifier.Show(notification);
            }
            catch
            {
            }
        }
Exemple #3
0
 public async Task <StorageFolder> GetDownloadFolder()
 {
     try
     {
         var           path   = _storageService.GetLocalSetting <string>("downloadfolder");
         StorageFolder folder = null;
         if (path == null)
         {
             folder = await PickDefaultDownloadFolder();
         }
         else
         {
             folder = await StorageFolder.GetFolderFromPathAsync(path);
         }
         return(folder);
     }
     catch
     {
         return(null);
     }
 }
Exemple #4
0
        public async Task <ShowModel> GetDetailHtml(string detailUri)
        {
            ShowModel model   = new ShowModel();
            string    html    = string.Empty;
            string    content = null;

            try
            {
                content = await _httpService.SendRequestForString(detailUri, HttpMethod.Get, Encoding.UTF8);
            }
            catch (Exception e)
            {
                throw new NetworkException("网路请求异常:" + e.Message);
            }

            try
            {
                var pasrser = new HtmlParser();
                var doc     = pasrser.ParseDocument(content);

                var isLiving = _storageService.GetLocalSetting <bool?>(Definition.KISSSUB_LIVING_MODE).Value;

                string torrent_url = null;
                string magnet_url  = null;
                if (isLiving)
                {
                    var hasCode = doc.Title.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Last();
                    torrent_url = $"http://v2.uploadbt.com/?r=down&hash={hasCode}";
                    magnet_url  = $"magnet:?xt=urn:btih:{hasCode}";
                }
                var ul   = doc.GetElementsByClassName("content detail").FirstOrDefault();
                var imgs = ul.QuerySelectorAll("img");
                foreach (var item in imgs)
                {
                    item.SetAttribute("width", "100%");
                }
                model.Summary = "<div style=\"width:100%\">" + ul.OuterHtml + "</div>";

                var file = doc.GetElementsByClassName("content").Skip(1).FirstOrDefault();
                imgs = file.QuerySelectorAll("img");
                foreach (var item in imgs)
                {
                    var link = item.GetAttribute("src");
                    item.SetAttribute("src", KISSSUB_HOME + link);
                }
                model.FileInfo = file.OuterHtml;

                if (isLiving)
                {
                    model.BtLink     = torrent_url;
                    model.MagnetLink = magnet_url;
                }
                else
                {
                    var div = doc.GetElementsByClassName("down").FirstOrDefault();
                    if (div != null)
                    {
                        var link = KISSSUB_HOME + div.Children[0].GetElementsByTagName("a").FirstOrDefault().GetAttribute("href");
                        model.BtLink     = link;
                        link             = div.Children[1].GetElementsByTagName("a").FirstOrDefault().GetAttribute("onclick");
                        link             = Regex.Match(link, @"magnet[\w\W]*(?=')").ToString();
                        model.MagnetLink = link;
                    }
                }
                return(model);
            }
            catch (Exception e)
            {
                throw new ResolveException("解析数据异常:" + e.Message);
            }
        }