public static Response<VideoInfo> VideoInfoResponse(Context Context, APIs.getthumbinfo.Serial.nicovideo_thumb_response Serial) { var result = new Response<VideoInfo>(); Response(result, Serial.status, Serial.error); if (Serial.thumb != null) { result.Result = Context.IDContainer.GetVideoInfo(Serial.thumb.video_id); result.Result.ComentCounter = Serial.thumb.comment_num; result.Result.Description = Serial.thumb.description; result.Result.EconomyVideoSize = Serial.thumb.size_low; result.Result.IsExternalPlay = Serial.thumb.embeddable; result.Result.Length = UNicoAPI2.Converter.TimeSpan(Serial.thumb.length); result.Result.MylistCounter = Serial.thumb.mylist_counter; result.Result.IsLivePlay = !Serial.thumb.no_live_play; result.Result.PostTime = DateTime.Parse(Serial.thumb.first_retrieve); result.Result.Tags = Tags(Serial.thumb.tags); result.Result.Title = Serial.thumb.title; result.Result.VideoSize = Serial.thumb.size_high; result.Result.VideoType = Serial.thumb.movie_type; result.Result.ViewCounter = Serial.thumb.view_counter; result.Result.Thumbnail = new Picture(Serial.thumb.thumbnail_url, Context.CookieContainer); result.Result.User = Context.IDContainer.GetUser(Serial.thumb.user_id); result.Result.User.Name = Serial.thumb.user_nickname; result.Result.User.Icon = new Picture(Serial.thumb.user_icon_url, Context.CookieContainer); } return result; }
public static Response<Tag[]> TagsResponse(APIs.tag_edit.Serial.contract Serial) { var result = new Response<Tag[]>(); Response(result, Serial.status, new APIs.Serial.error() { description = Serial.error_msg }); result.Result = Tags(Serial.tags); return result; }
public static Response<Comment[]> CommentResponse(APIs.download_comment.Serial.packet Serial) { var result = new Response<Comment[]>(); Response(result, "ok", null); result.Result = Comment(Serial.chat); return result; }
/********************************************/ public static Response<VideoInfo[]> VideoInfoResponse(Context Context, APIs.search.Serial.contract Serial) { var result = new Response<VideoInfo[]>(); Response(result, Serial.status, Serial.error); result.Result = VideoInfos(Context, Serial.list); return result; }
public static Response Response(APIs.upload_comment.Serial.packet Serial) { var result = new Response(); if (Serial.chat_result.status == "0") result.Status = Status.OK; else { switch (Serial.chat_result.status) { case "1": result.ErrorMessage = "同じコメントを投稿しようとしました"; break; case "3": result.ErrorMessage = "投稿するためのキーが足りませんでした"; break; default: break; } result.Status = Status.UnknownError; } return result; }
public static Response<Mylist.Mylist> MylistResponse(Context Context, APIs.mylistvideo.Serial.contract Serial, string MylistID) { var result = new Response<Mylist.Mylist>(); Response(result, Serial.status, Serial.error); result.Result = Context.IDContainer.GetMylist(MylistID); result.Result.Description = Serial.description; result.Result.Title = Serial.name; result.Result.IsBookmark = Serial.is_watching_this_mylist; result.Result.MylistItem = MylistItem(Context, Serial.list); if (Serial.user_id != null) { result.Result.User = Context.IDContainer.GetUser(Serial.user_id); result.Result.User.Name = Serial.user_nickname; } return result; }
/********************************************/ public static void Response(Response Response, string Status, APIs.Serial.error Error) { switch (Status) { case "ok": Response.Status = VideoService.Status.OK; break; case "fail": if (Error == null) { Response.Status = VideoService.Status.UnknownError; break; } switch (Error.code) { case "DELETED": Response.Status = VideoService.Status.Deleted; break; default: Response.Status = VideoService.Status.UnknownError; break; } Response.ErrorMessage = Error.description; break; } }
public static Response<Mylist.Mylist[]> PublicMylistListResponse(Context context, Dictionary<string, string>[] Serial) { var result = new Response<Mylist.Mylist[]>(); Response(result, "ok", null); result.Result = new Mylist.Mylist[Serial.Length]; for (int i = 0; i < result.Result.Length; i++) { result.Result[i] = context.IDContainer.GetMylist(Serial[i]["id"]); result.Result[i].Title = Serial[i]["name"]; } return result; }
public static Response<User.User> UserResponse(Context Context, Dictionary<string, string> Serial) { var result = new Response<User.User>(); Response(result, "ok", null); result.Result = Context.IDContainer.GetUser(Serial["id"]); result.Result.Icon = new Picture(Serial["icon"], Context.CookieContainer); result.Result.Name = Serial["name"]; result.Result.Sex = Serial["sex"]; result.Result.Birthday = Serial["birthday"]; result.Result.Area = Serial["area"]; result.Result.Description = Serial["description"]; try { result.Result.BookmarkCount = int.Parse(Serial["bookmark"]); result.Result.Experience = int.Parse(Serial["exp"]); } catch (Exception) { } return result; }