Esempio n. 1
0
 public void GetMp3(Root resultRoot)
 {
     foreach (var episode in resultRoot.info.episodes.episode)
     {
         //获取FM当前小说下所有的话ID
         RootGetdound result =
             JsonConvert.DeserializeObject <RootGetdound>(PostTool.Get(Getsound + episode.sound_id));
         if (result.success)
         {
             var filename      = resultRoot.info.drama.name.Replace('/', ' ');
             var directorypath = Downstr + filename + "/" + episode.name;
             if (!Directory.Exists(directorypath))
             {
                 Directory.CreateDirectory(directorypath);
             }
             //发送开始下载信息
             messageSend.RegisterAction("Up_down_name", new Dictionary <string, string>
             {
                 { "name", episode.name }
             });
             var t1 = new Task(() => GetImages(directorypath + "/Images", episode));
             t1.Start();
             DownloadFile(result.info.sound.soundurl, directorypath + "/" + episode.name + ".MP3"); //下载文件
             Task.WaitAll(t1);                                                                      //等待本轮任务结束
         }
     }
 }
Esempio n. 2
0
        public void GetImages(string saveAddress, Episode episode)
        {
            if (!Directory.Exists(saveAddress))
            {
                Directory.CreateDirectory(saveAddress);
            }
            //获取FM当前小说的当前会话的所有图片
            RootImage result = JsonConvert.DeserializeObject <RootImage>(PostTool.Get(Getimages + episode.sound_id));

            if (result.success.Equals(ErrorCode.Success))
            {
                int current = 1;
                foreach (var item in result.successVal.images.OrderBy(s => s[5]))
                {
                    string filename = item[5] + "." + item.First().Split('.')[1];
                    if (filename.Contains("/"))
                    {
                        filename = filename.Remove(0, count: filename.LastIndexOf("/", StringComparison.Ordinal));
                        filename = filename.Replace("/", string.Empty);
                    }

                    DownloadImageFile(ImagesAdress + item.First(), saveAddress + "/" + filename); //下载文件
                    //发送开始下载信息
                    messageSend.RegisterAction("Up_down_all", new Dictionary <string, string>
                    {
                        { "imgDwBar_Maximum", result.successVal.images.Count.ToString() },
                        { "imgDwBar_Value", current.ToString() },
                        { "imgDown", $@"{episode.name} {result.successVal.images.Count}/{current}" }
                    });
                    current++;
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 查询当前FM
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public object Select(string id)
 {
     if (id == null)
     {
         throw new ArgumentNullException(nameof(id));
     }
     try
     {
         //获取FM当前小说下所有的话ID
         Root result = JsonConvert.DeserializeObject <Root>(PostTool.Get(Getdrama + id.Trim()));
         if (result.success)
         {
             return(result);
         }
         return(null);
     }
     catch (Exception e)
     {
         LogHelper.ErrorLog(ErrorCode.SelectError, e);
         return(null);
     }
 }