Exemple #1
0
        private async void StartVideoDownload(object par)
        {
            try
            {
                Loading.IsVisible = true;
                var item = par as pagesModel;
                var data = BindingContext as VideoInfoModel;
                List <segment_listModel> segment_list = new List <segment_listModel>();
                var indexJsonContent = "";
                var entryJsonContent = "";
                var description      = "超清";

                int q = 3;
                //转换下清晰度
                var quality = "lua.flv720.bb2api.64";
                switch (SettingHelper.GetQuality())
                {
                case 0:
                    quality     = "lua.hdflv2.bb2api.bd";
                    description = "1080P";
                    q           = 4;
                    break;

                case 1:
                    quality     = "lua.flv.bb2api.80";
                    description = "超清";
                    q           = 3;
                    break;

                case 2:
                    quality     = "lua.flv720.bb2api.64";
                    description = "高清";
                    q           = 2;
                    break;

                case 3:
                    quality     = "lua.mp4.bb2api.16";
                    description = "清晰";
                    q           = 1;
                    break;

                default:
                    break;
                }


                EntryModel entryModel = new EntryModel()
                {
                    avid              = _aid,
                    title             = data.title,
                    cover             = data.pic,
                    type_tag          = quality,
                    time_create_stamp = Api.GetTimeSpan_2,
                    time_update_stamp = Api.GetTimeSpan_2,
                    page_data         = new page_dataModel()
                    {
                        cid  = item.cid,
                        from = item.from,
                        part = item.part,
                        vid  = item.vid,
                        tid  = data.tid,
                        page = item.page
                    }
                };
                //调用系统下载时将任务设置未完成
                if (_downlaodType == DownlaodType.System)
                {
                    entryModel.is_completed = true;
                }
                else
                {
                    entryModel.is_completed = false;
                }
                //当调用系统下载时才读取地址
                if (_downlaodType == DownlaodType.System)
                {
                    segment_list = await Util.GetVideoUrl(item.cid.ToString(), "https://www.bilibili.com/video/av16111678", q, "", 0);

                    long _tbyte      = 0;
                    long _timelength = 0;
                    foreach (var item1 in segment_list)
                    {
                        _tbyte      += item1.bytes;
                        _timelength += item1.duration;
                    }
                    DownIndexModel downUrlModel = new DownIndexModel()
                    {
                        type_tag              = quality,
                        description           = description,
                        parse_timestamp_milli = Api.GetTimeSpan_2,
                        time_length           = _timelength
                    };

                    downUrlModel.segment_list = segment_list;
                    List <player_codec_config_listModel> player_Codec_Config_ListModel = new List <player_codec_config_listModel>()
                    {
                        new  player_codec_config_listModel()
                        {
                            player = "IJK_PLAYER"
                        },
                        new player_codec_config_listModel()
                        {
                            player = "ANDROID_PLAYER"
                        }
                    };
                    downUrlModel.player_codec_config_list = player_Codec_Config_ListModel;
                    indexJsonContent            = JsonConvert.SerializeObject(downUrlModel);
                    entryModel.total_time_milli = downUrlModel.time_length;
                    entryModel.total_bytes      = _tbyte;
                }


                //序列化entryModel
                entryJsonContent = JsonConvert.SerializeObject(entryModel);


                //开始一个下载任务
                StartDownModel startDownModel = new StartDownModel()
                {
                    downPath      = SettingHelper.GetDownPath(),
                    entry_content = entryJsonContent,
                    av_id         = _aid,
                    danmaku_id    = item.cid.ToString(),
                    episode_id    = "",
                    index_content = indexJsonContent,
                    quality       = quality,
                    season_id     = "",
                    title         = item.page + " " + item.part,
                    urls          = segment_list,
                    page          = item.page,
                    clientType    = (ClientType)SettingHelper.GetClientMode(),
                    downlaodType  = _downlaodType,
                    videoType     = _videoType
                };
                var msg = Util.StartDownload(startDownModel);
                if (msg.code == 200)
                {
                    Util.ShowShortToast(msg.message);
                }
                else
                {
                    await DisplayAlert("创建任务失败", msg.message, "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("好气啊,出错了", ex.Message, "OK");
            }
            finally
            {
                Loading.IsVisible = false;
            }
        }
Exemple #2
0
        private async void StartAnimeDownload(object par)
        {
            try
            {
                Loading.IsVisible = true;
                if (_videoType == VideoType.AreaAnime)
                {
                    _downlaodType = DownlaodType.System;
                }


                var item = par as episodesModel;
                var data = BindingContext as BangumiInfoModel;
                List <segment_listModel> segment_list = new List <segment_listModel>();
                var indexJsonContent = "";
                var entryJsonContent = "";
                var description      = "超清";

                int q = 3;
                //转换下清晰度
                var quality       = "lua.flv720.bb2api.64";
                var video_quality = 112;
                switch (SettingHelper.GetQuality())
                {
                case 0:
                    quality       = "lua.hdflv2.bb2api.bd";
                    description   = "1080P";
                    q             = 4;
                    video_quality = 112;
                    break;

                case 1:
                    quality       = "lua.flv.bb2api.80";
                    description   = "超清";
                    video_quality = 80;
                    q             = 3;
                    break;

                case 2:
                    quality       = "lua.flv720.bb2api.64";
                    description   = "高清";
                    video_quality = 64;
                    q             = 2;
                    break;

                case 3:
                    quality       = "lua.mp4.bb2api.16";
                    description   = "清晰";
                    video_quality = 16;
                    q             = 1;
                    break;

                default:
                    break;
                }


                EntryModel entryModel = new EntryModel()
                {
                    season_id              = data.season_id,
                    title                  = data.title,
                    cover                  = data.cover,
                    type_tag               = quality,
                    time_create_stamp      = Api.GetTimeSpan_2,
                    time_update_stamp      = Api.GetTimeSpan_2,
                    prefered_video_quality = video_quality,
                    source                 = new sourceModel()
                    {
                        av_id       = long.Parse(item.aid),
                        cid         = item.cid,
                        website     = "bangumi",
                        webvideo_id = ""
                    },
                    ep = new epModel()
                    {
                        av_id       = long.Parse(item.aid),
                        danmaku     = item.cid,
                        cover       = item.cover,
                        episode_id  = long.Parse(item.ep_id),
                        index       = item.index,
                        orderindex  = item.orderindex,
                        index_title = item.index_title,
                        page        = item.page
                    }
                };
                //调用系统时将任务设置未完成
                if (_downlaodType == DownlaodType.System)
                {
                    entryModel.is_completed = true;
                }
                else
                {
                    entryModel.is_completed = false;
                }
                //当调用系统下载时才读取地址
                if (_downlaodType == DownlaodType.System)
                {
                    segment_list = await Util.GetVideoUrl(entryModel.ep.danmaku.ToString(), "https://www.bilibili.com/bangumi/play/ep" + entryModel.ep.episode_id, q, _sid, entryModel.ep.orderindex);

                    long _tbyte      = 0;
                    long _timelength = 0;
                    foreach (var item1 in segment_list)
                    {
                        _tbyte      += item1.bytes;
                        _timelength += item1.duration;
                    }
                    DownIndexModel downUrlModel = new DownIndexModel()
                    {
                        type_tag              = quality,
                        description           = description,
                        parse_timestamp_milli = Api.GetTimeSpan_2,
                        time_length           = _timelength
                    };

                    downUrlModel.segment_list = segment_list;
                    List <player_codec_config_listModel> player_Codec_Config_ListModel = new List <player_codec_config_listModel>()
                    {
                        new  player_codec_config_listModel()
                        {
                            player = "IJK_PLAYER"
                        },
                        new player_codec_config_listModel()
                        {
                            player = "ANDROID_PLAYER"
                        }
                    };
                    downUrlModel.player_codec_config_list = player_Codec_Config_ListModel;
                    indexJsonContent            = JsonConvert.SerializeObject(downUrlModel);
                    entryModel.total_time_milli = downUrlModel.time_length;
                    entryModel.total_bytes      = _tbyte;
                }


                //序列化entryModel
                entryJsonContent = JsonConvert.SerializeObject(entryModel);


                //开始一个下载任务
                StartDownModel startDownModel = new StartDownModel()
                {
                    downPath      = SettingHelper.GetDownPath(),
                    entry_content = entryJsonContent,
                    av_id         = entryModel.ep.av_id.ToString(),
                    danmaku_id    = entryModel.ep.danmaku.ToString(),
                    episode_id    = entryModel.ep.episode_id.ToString(),
                    index_content = indexJsonContent,
                    quality       = quality,
                    season_id     = _sid,
                    title         = entryModel.ep.index + entryModel.ep.index_title,
                    urls          = segment_list,
                    clientType    = (ClientType)SettingHelper.GetClientMode(),
                    downlaodType  = _downlaodType,
                    videoType     = _videoType
                };
                var msg = Util.StartDownload(startDownModel);
                if (msg.code == 200)
                {
                    Util.ShowShortToast(msg.message);
                }
                else
                {
                    await DisplayAlert("创建任务失败", msg.message, "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("好气啊,出错了", ex.Message, "OK");
            }
            finally
            {
                Loading.IsVisible = false;
            }
        }