/// <summary> /// 获取房间信息 /// </summary> /// <param name="item">任务实例</param> /// <returns></returns> public static bool GetRoomInfo(ref Cls_WorkListItem item) { try { string str = Bas.GetBody(item.URL); if (!string.IsNullOrEmpty(str)) { Regex reg = new Regex("<script>window.__NEPTUNE_IS_MY_WAIFU__={.*}</script>"); string jsonstr = reg.Match(str).Value; jsonstr = Regex.Split(Regex.Split(jsonstr, "window.__NEPTUNE_IS_MY_WAIFU__=")[1], "</script>")[0]; item.Platform = Cls_WorkListItem.PlatformType.Bilibili; item.Roomid = Bas.GetJsonValueByKey(jsonstr, "roomInitRes/data/room_id").ToString(); item.RoomStatus = (int)Bas.GetJsonValueByKey(jsonstr, "roomInitRes/data/live_status"); item.RoomTitle = Bas.GetJsonValueByKey(jsonstr, "baseInfoRes/data/title").ToString(); if (item.RoomStatus == 1) { List <string> Urls = new List <string>(); foreach (Dictionary <string, object> i in (ArrayList)Bas.GetJsonValueByKey(jsonstr, "playUrlRes/data/durl")) { Urls.Add(Bas.GetJsonValueByKey(i, "url").ToString()); } item.VideoUrl = Urls.ToArray(); } item.IsSupportDanmu = true; if (str.Contains("uname")) { item.Host = Regex.Split(new Regex("\"uname\":.*,").Match(str).Value, "\"")[3]; } else { string strhost = Bas.GetBody("https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=" + item.Roomid); item.Host = Bas.GetJsonValueByKey(strhost, "data/info/uname").ToString(); } item.CallPropertyChanged("RoomInfoLong"); return(true); } else { item.Platform = Cls_WorkListItem.PlatformType.None; item.CallPropertyChanged("RoomInfoLong"); return(false); } } catch { return(false); } }
/// <summary> /// 修改任务构造函数 /// </summary> /// <param name="Item"></param> public TaskSettingWindow(Cls_WorkListItem Item, WorkList TaskList) { InitializeComponent(); this.TaskList = TaskList; this.Item = Item; SetBinding(); }
/// <summary> /// 新建任务构造函数 /// </summary> public TaskSettingWindow(WorkList TaskList) { InitializeComponent(); this.TaskList = TaskList; Item = new Cls_WorkListItem(); IsNew = true; SetBinding(); }
/// <summary> /// 子控件选中调用 /// </summary> /// <param name="item">子控件实例</param> /// <param name="task">任务实例</param> /// <param name="IsSelected">指示是否选中</param> public void ItemSelected(WorkListItem item, Cls_WorkListItem task, bool IsSelected) { if (IsSelected) { SelectedList.Add(new SelectedItem() { Item = item, Task = task }); } else { SelectedList.Remove(new SelectedItem() { Item = item, Task = task }); } }
/// <summary> /// URL解析 /// </summary> /// <param name="URL"></param> /// <returns></returns> public static void AnalysisURL(string URL, ref Cls_WorkListItem item) { if (URL.Length == 0) { return; } Regex reg = new Regex("[^\\s]/\\d+"); if (URL.Contains("live.bilibili.com") && reg.Match(URL).Success) { item.URL = URL; B_Live.GetRoomInfo(ref item); } else { item.Platform = Cls_WorkListItem.PlatformType.None; item.CallPropertyChanged("RoomInfoLong"); } }
public WorkListItem(Cls_WorkListItem Item, WorkList Parent) { InitializeComponent(); this.Item = Item; this.Parent = Parent; Binding bindTitle = new Binding { Source = Item, Mode = BindingMode.OneWay, Path = new System.Windows.PropertyPath("RoomTitle") }; BindingOperations.SetBinding(lbl_RoomTitle, ContentProperty, bindTitle); Binding bindInfo = new Binding { Source = Item, Mode = BindingMode.OneWay, Path = new System.Windows.PropertyPath("RoomInfo") }; BindingOperations.SetBinding(lbl_RoomInfo, ContentProperty, bindInfo); Binding bindStatus = new Binding { Source = Item, Mode = BindingMode.OneWay, Path = new System.Windows.PropertyPath("StatusString") }; BindingOperations.SetBinding(lbl_TaskStatus, ContentProperty, bindStatus); //Binding bindStatuscolor = new Binding //{ // Source = Item, // Mode = BindingMode.OneWay, // Path = new System.Windows.PropertyPath("StatusColor") //}; //BindingOperations.SetBinding(lbl_TaskStatus, ForegroundProperty, bindStatuscolor); }
/// <summary> /// 读取任务列表 /// </summary> public static void LoadTasks() { if (File.Exists(Properties.Settings.Default.SavePath + "\\tasks.json")) { FileStream fs = new FileStream(Properties.Settings.Default.SavePath + "\\tasks.json", FileMode.Open); StreamReader reader = new StreamReader(fs); string json = reader.ReadToEnd(); fs.Close(); ArrayList al = (ArrayList)GetJsonValueByKey(json, "tasks"); foreach (Dictionary <string, object> i in al) { Cls_WorkListItem c = new Cls_WorkListItem { Frequency = GetJsonValueByKey(i, "Frequency")?.ToString(), Host = GetJsonValueByKey(i, "Host").ToString(), IsRecordDanmu = (bool)GetJsonValueByKey(i, "IsRecordDanmu"), IsRepeat = (bool)GetJsonValueByKey(i, "IsRepeat"), IsSupportDanmu = (bool)GetJsonValueByKey(i, "IsSupportDanmu"), IsTranslateAfterCompleted = (bool)GetJsonValueByKey(i, "IsTranslateAfterCompleted"), Platform = (Cls_WorkListItem.PlatformType)GetJsonValueByKey(i, "Platform"), RoomStatus = (int)GetJsonValueByKey(i, "RoomStatus"), RoomTitle = GetJsonValueByKey(i, "RoomTitle").ToString(), Roomid = GetJsonValueByKey(i, "Roomid").ToString(), StartMode = (Cls_WorkListItem.StartModeType)GetJsonValueByKey(i, "StartMode"), StartTime = DateTime.Parse(GetJsonValueByKey(i, "StartTime")?.ToString()) }; c.StartTime = c.StartTime.AddHours(8); c.Status = (Cls_WorkListItem.StatusCode)GetJsonValueByKey(i, "Status"); c.URL = GetJsonValueByKey(i, "URL").ToString(); c.SettingFinished(); TaskList.Add(c); ((MainWindow)Application.Current.MainWindow).WorkList.AddTask(c); } } }
/// <summary> /// 添加任务 /// </summary> /// <param name="task"></param> public void AddTask(Cls_WorkListItem task) { Container.Children.Add(new WorkListItem(task, this)); RefreshNoitce(); }
public TimeSetterWindow(Cls_WorkListItem Item) { InitializeComponent(); this.Item = Item; }