public async Task GetLiveRecordListTestAsync() { using var client = new BililiveApiClient(); var json = await client.GetLiveRecordListAsync(6154037); Assert.AreEqual(json.code, 0); Assert.AreEqual(json.message, @"0"); var all = json.data.count; Assert.IsTrue(all > 0); json = await client.GetLiveRecordListAsync(6154037, 1, all); Assert.AreEqual(json.code, 0); Assert.AreEqual(json.message, @"0"); Assert.IsTrue(json.data.count > 0); Assert.IsTrue(json.data.list.Length > 0); Assert.IsTrue(json.data.list.Length == all); foreach (var data in json.data.list) { Assert.IsFalse(string.IsNullOrEmpty(data.rid)); Assert.IsFalse(string.IsNullOrEmpty(data.title)); Assert.IsFalse(string.IsNullOrEmpty(data.cover)); Assert.IsFalse(string.IsNullOrEmpty(data.area_name)); Assert.IsFalse(string.IsNullOrEmpty(data.parent_area_name)); Assert.IsTrue(data.start_timestamp > 0); Assert.IsTrue(data.end_timestamp > 0); Assert.IsTrue(data.end_timestamp > data.start_timestamp); Assert.IsTrue(data.online > 0); Assert.IsTrue(data.danmu_num > 0); Assert.IsTrue(data.length > 0); Assert.IsTrue((data.end_timestamp - data.start_timestamp) * 1000 >= data.length); } }
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); }
public async Task GetRoomInitTestAsync() { using var client = new BililiveApiClient(); var json = await client.GetRoomInitAsync(732); Assert.AreEqual(json.code, 0); Assert.AreEqual(json.msg, @"ok"); Assert.AreEqual(json.message, @"ok"); Assert.AreEqual(json.data.room_id, 6154037); Assert.AreEqual(json.data.short_id, 732); Assert.AreEqual(json.data.uid, 194484313); }
public async Task GetAnchorInfoTestAsync() { using var client = new BililiveApiClient(); var json = await client.GetAnchorInfoAsync(732); Assert.AreEqual(json.code, 0); Assert.AreEqual(json.msg, @"success"); Assert.AreEqual(json.message, @"success"); Assert.AreEqual(json.data.info.uid, 194484313); Assert.AreEqual(json.data.info.uname, @"Asaki大人"); Assert.IsTrue(json.data.info.face.StartsWith(@"https://")); Assert.AreEqual(json.data.info.platform_user_level, 6); }
public async Task GetDanmuConfTestAsync() { using var client = new BililiveApiClient(); var json = await client.GetDanmuConfAsync(6154037); Assert.AreEqual(json.code, 0); Assert.AreEqual(json.msg, @"ok"); Assert.AreEqual(json.message, @"ok"); Assert.AreEqual(json.data.port, 2243); Assert.AreEqual(json.data.host, @"broadcastlv.chat.bilibili.com"); Assert.IsTrue(json.data.host_server_list.Length > 0); Assert.IsTrue(json.data.server_list.Length > 0); Assert.IsTrue(!string.IsNullOrWhiteSpace(json.data.token)); }
public UserSettingsViewModel( IScreen hostScreen, ILogger <UserSettingsViewModel> logger, Config config, BililiveApiClient apiClient) { HostScreen = hostScreen; _logger = logger; Config = config; _apiClient = apiClient; QrCodeLoginCommand = ReactiveCommand.CreateFromTask(QrCodeLoginAsync); CheckLoginCommand = ReactiveCommand.CreateFromTask(CheckLoginAsync); }
public QrCodeLoginDialog(GetLoginUrlData data) { _logger = DI.GetService <ILogger <QrCodeLoginDialog> >(); _apiClient = DI.GetService <BililiveApiClient>(); _data = data; InitializeComponent(); using var qrGenerator = new QRCodeGenerator(); using var qrCodeData = qrGenerator.CreateQrCode(data.url, QRCodeGenerator.ECCLevel.H, true); using var qrCode = new XamlQRCode(qrCodeData); QrCodeImage.Source = qrCode.GetGraphic(20); _loginInfoMonitor = CreateMonitor(); PrimaryButtonCommand = ReactiveCommand.CreateFromTask(GetLoginInfoAsync); }
public LiveRecordListViewModel( IScreen hostScreen, ILogger <LiveRecordListViewModel> logger, Config config, SourceList <LiveRecordList> liveRecordSourceList, TaskListViewModel taskList, BililiveApiClient apiClient) { HostScreen = hostScreen; _logger = logger; Config = config; _taskList = taskList; _liveRecordSourceList = liveRecordSourceList; _apiClient = apiClient; _roomIdMonitor = this .WhenAnyValue(x => x.Config.RoomId, x => x.TriggerLiveRecordListQuery) .Throttle(TimeSpan.FromMilliseconds(800), RxApp.MainThreadScheduler) .DistinctUntilChanged() .Where(i => i.Item1 > 0) .Select(i => i.Item1) .Subscribe(i => { GetAnchorInfoAsync(i).NoWarning(); GetRecordListAsync(i).NoWarning(); }); _liveRecordSourceList.Connect() .Transform(x => new LiveRecordViewModel(x)) .ObserveOnDispatcher() .Bind(out LiveRecordList) .DisposeMany() .Subscribe(); CopyLiveRecordDownloadUrlCommand = ReactiveCommand.CreateFromTask <object?>(CopyLiveRecordDownloadUrlAsync); OpenLiveRecordUrlCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(OpenLiveRecordUrl); OpenDirCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(OpenDir); DownLoadCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(Download); }