Пример #1
0
        private async Task CopyLiveRecordDownloadUrlAsync(object?info)
        {
            try
            {
                if (info is LiveRecordViewModel liveRecord && !string.IsNullOrEmpty(liveRecord.Rid))
                {
                    var message = await _apiClient.GetLiveRecordUrlAsync(liveRecord.Rid);

                    var list = message?.data?.list;
                    if (list is not null &&
                        list.Length > 0 &&
                        list.All(x => !string.IsNullOrEmpty(x.url) || !string.IsNullOrEmpty(x.backup_url))
                        )
                    {
                        Utils.Utils.CopyToClipboard(string.Join(Environment.NewLine,
                                                                list.Select(x => string.IsNullOrEmpty(x.url) ? x.backup_url : x.url)
                                                                ));
                    }
                }
            }
            catch
            {
                //ignored
            }
        }
        public async Task GetLiveRecordUrlTestAsync()
        {
            using var client = new BililiveApiClient();
            var json = await client.GetLiveRecordUrlAsync(@"R1zx411c75j");             // 视频链接会过期

            Assert.AreEqual(json.code, 0);
            Assert.AreEqual(json.message, @"0");
            Assert.IsTrue(json.data.size > 0);
            Assert.IsTrue(json.data.length > 0);
            Assert.IsTrue(json.data.list.Length > 0);
        }