Ejemplo n.º 1
0
        /*目录结构
         * /哔哩哔哩下载目录
         *      番剧
         *          剧集
         *              视频目录
         *                  index.json
         *                  0.blv
         *                  0.0.blv.4m.sum
         *              entry.json
         *              danmaku.xml
         */
        private MsgModel ClientDownloadAnime(StartDownModel startDownModel)
        {
            try
            {
                var biliPath = startDownModel.downPath + "/tv.danmaku.bili/download/";
                if (startDownModel.clientType == ClientType.blue)
                {
                    biliPath = startDownModel.downPath + "/com.bilibili.app.blue/download/";
                }
                Java.IO.File bilidirv = new Java.IO.File(biliPath);
                if (!bilidirv.Exists())
                {
                    bilidirv.Mkdirs();
                    //return new MsgModel() { message = "请检查你是否安装了哔哩哔哩客户端或者是否更改了哔哩哔哩客户端的下载目录" };
                }

                //番剧目录
                string       path = biliPath + "s_" + startDownModel.season_id + "/";
                Java.IO.File dirv = CreateFolder(path);

                //剧集目录
                string       e_path      = path + startDownModel.episode_id + "/";
                Java.IO.File e_path_dirv = CreateFolder(e_path);

                //剧集entry.json文件
                string       json_path      = e_path + "/entry.json";
                Java.IO.File json_path_file = CreateFile(json_path);
                WriteFileContent(json_path, startDownModel.entry_content);
                //剧集弹幕文件
                string       danmu_path      = e_path + "/danmaku.xml";
                Java.IO.File danmu_path_file = CreateFile(danmu_path);


                //剧集视频文件夹
                string       video_path      = e_path + "/" + startDownModel.quality + "/";
                Java.IO.File video_path_dirv = CreateFolder(video_path);

                //剧集视频index.json
                string       indexjson_path      = video_path + "index.json";
                Java.IO.File indexjson_path_file = CreateFile(indexjson_path);
                WriteFileContent(indexjson_path, startDownModel.index_content);


                return(new MsgModel()
                {
                    code = 200, message = "任务创建成功,请打开哔哩哔哩客户端查看"
                });
            }
            catch (Exception ex)
            {
                return(new MsgModel()
                {
                    code = ex.HResult, message = "任务创建失败,出现了未知错误\r\n" + ex.Message
                });
            }
        }
Ejemplo n.º 2
0
        public MsgModel StartDownload(StartDownModel startDownModel)
        {
            switch (startDownModel.videoType)
            {
            case VideoType.Anime:
                if (startDownModel.downlaodType == DownlaodType.Bilibili)
                {
                    return(ClientDownloadAnime(startDownModel));
                }
                else
                {
                    return(SystemDownloadAnime(startDownModel));
                }

            case VideoType.AreaAnime:
                return(SystemDownloadAnime(startDownModel));

            case VideoType.Video:
            case VideoType.Movie:
            case VideoType.VipMovie:
                if (startDownModel.downlaodType == DownlaodType.Bilibili)
                {
                    return(ClientDownloadVideo(startDownModel));
                }
                else
                {
                    return(SystemDownloadVideo(startDownModel));
                }

            default:
                return(new MsgModel()
                {
                    message = "不支持此类型的视频下载"
                });
            }
        }
Ejemplo n.º 3
0
        private MsgModel SystemDownloadVideo(StartDownModel startDownModel)
        {
            try
            {
                var          biliPath = startDownModel.downPath + GetLocalPath(startDownModel.clientType);
                Java.IO.File bilidirv = new Java.IO.File(biliPath);
                if (!bilidirv.Exists())
                {
                    bilidirv.Mkdirs();
                    //return new MsgModel() { message = "请检查你是否安装了哔哩哔哩客户端或者是否更改了哔哩哔哩客户端的下载目录" };
                }
                //视频目录
                string       path = biliPath + startDownModel.av_id + "/";
                Java.IO.File dirv = CreateFolder(path);

                //剧集目录
                string       e_path      = path + startDownModel.page + "/";
                Java.IO.File e_path_dirv = CreateFolder(e_path);

                //剧集entry.json文件
                string       json_path      = e_path + "/entry.json";
                Java.IO.File json_path_file = CreateFile(json_path);
                WriteFileContent(json_path, startDownModel.entry_content);
                //剧集弹幕文件
                string       danmu_path      = e_path + "/danmaku.xml";
                Java.IO.File danmu_path_file = CreateFile(danmu_path);


                //剧集视频文件夹
                string       video_path      = e_path + "/" + startDownModel.quality + "/";
                Java.IO.File video_path_dirv = CreateFolder(video_path);

                //剧集视频index.json
                string       indexjson_path      = video_path + "index.json";
                Java.IO.File indexjson_path_file = CreateFile(indexjson_path);
                WriteFileContent(indexjson_path, startDownModel.index_content);

                for (int i = 0; i < startDownModel.urls.Count; i++)
                {
                    string       sum_path      = video_path + i + ".blv.4m.sum";
                    Java.IO.File sum_path_file = CreateFile(sum_path);
                    WriteFileContent(sum_path, "{\"length\":" + startDownModel.urls[i].bytes + "}");

                    string       blv_path      = video_path + i + ".blv";
                    Java.IO.File blv_path_file = new Java.IO.File(blv_path);

                    var download_id = CreateSystemDownloadTask(startDownModel.urls[i].url, blv_path_file, "https://www.bilibili.com/video/av" + startDownModel.av_id, startDownModel.title + i);
                }


                return(new MsgModel()
                {
                    code = 200, message = "任务创建成功,请等待下载完成打开哔哩哔哩客户端观看"
                });
            }
            catch (Exception ex)
            {
                return(new MsgModel()
                {
                    code = ex.HResult, message = "任务创建失败,出现了未处理错误\r\n" + ex.Message
                });
            }
        }
Ejemplo n.º 4
0
 public static MsgModel StartDownload(StartDownModel m)
 {
     return(DependencyService.Get <IDownloadHelper>().StartDownload(m));
 }