@@ -127,7 +127,7 @@ public static async Task<long[]> GetBlockList(IDataServer server, List<Cookie> c
127127 {
128128 var url = $ "https://live-api.line-apps.com/web/v4.0/channel/{ channelId } /broadcast/{ liveId } ";
129129 var res = await server . GetAsync ( url ) ; //, cc);
130-
130+ //{"status":4030005,"errorMessage":"LIVE Gateway Failed","apistatusCode":4030005}
131131 dynamic d = Tools . Deserialize ( res ) ;
132132 var liveInfo = new LiveInfo
133133 {
@@ -144,11 +144,16 @@ public static async Task<long[]> GetBlockList(IDataServer server, List<Cookie> c
144144 var channelInfo = Tools . Deserialize < LineLiveSitePlugin . Low . ChannelInfo . RootObject > ( s ) ;
145145 return ( channelInfo , s ) ;
146146 }
147- public static async Task < LineLiveSitePlugin . Low . Loves . RootObject > GetLoves ( IDataServer server )
147+ public static async Task < LineLive . Api . Loves > GetLovesV4 ( IDataServer server )
148148 {
149- var url = "https://live-api.line-apps.com/web/v2.5/billing/gift/loves" ;
150- var s = await server . GetAsync ( url ) ;
151- var loves = Tools . Deserialize < LineLiveSitePlugin . Low . Loves . RootObject > ( s ) ;
149+ //https://live-api.line-apps.com/web/v4.0/billing/gift/loves?storeType=WEB&channelId={channelId}&broadcastId={broadcastId}
150+ var url = "https://live-api.line-apps.com/web/v4.0/billing/gift/loves" ;
151+ var headers = new Dictionary < string , string >
152+ {
153+ { "Accept-Language" , "ja" } ,
154+ } ;
155+ var s = await server . GetAsync ( url , headers , new CookieContainer ( ) ) ;
156+ var loves = LineLive . Api . Loves . Parse ( s ) ;
152157 return loves ;
153158 }
154159 public static async Task < Me > GetMyAsync ( IDataServer server , List < Cookie > cookies )
@@ -189,340 +194,3 @@ class Me
189194 public string UserId { get ; set ; }
190195 }
191196}
192-
193- //namespace LineLiveSitePlugin
194- //{ /// <summary>
195- // ///
196- // /// </summary>
197- // /// <remarks>接続毎にインスタンスを作る</remarks>
198- // class MessageProvider
199- // {
200- // public event EventHandler Opened;
201-
202- // public event EventHandler<Result> Received;
203- // WebSocket _ws;
204- // TaskCompletionSource<object> _tcs;
205- // public Task ReceiveAsync()
206- // {
207- // _tcs = new TaskCompletionSource<object>();
208- // var cookies = new List<KeyValuePair<string, string>>();
209- // _ws = new WebSocket("wss://irc-ws.chat.twitch.tv/", "", cookies);
210- // _ws.MessageReceived += _ws_MessageReceived;
211- // _ws.Opened += _ws_Opened;
212- // _ws.Error += _ws_Error;
213- // _ws.Closed += _ws_Closed;
214- // _ws.Open();
215- // return _tcs.Task;
216- // }
217-
218- // private void _ws_Closed(object sender, EventArgs e)
219- // {
220- // _tcs.SetResult(null);
221- // }
222-
223- // private void _ws_Error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
224- // {
225- // _tcs.SetException(e.Exception);
226- // }
227-
228- // private void _ws_Opened(object sender, EventArgs e)
229- // {
230- // Opened?.Invoke(this, e);
231- // }
232-
233- // public async Task SendAsync(string s)
234- // {
235- // Debug.WriteLine("send: " + s);
236- // await Task.Yield();
237- // _ws.Send(s + "\r\n");
238- // }
239-
240- // private void _ws_MessageReceived(object sender, MessageReceivedEventArgs e)
241- // {
242- // var arr = e.Message.Split(new[] { "\r\n" }, StringSplitOptions.None);
243- // foreach (var message in arr)
244- // {
245- // if (string.IsNullOrEmpty(message))
246- // continue;
247- // var result = Tools.Parse(message);
248- // Received?.Invoke(this, result);
249- // }
250- // }
251-
252- // public void Disconnect()
253- // {
254- // _ws?.Close();
255- // _ws = null;
256- // }
257- // public MessageProvider()
258- // {
259-
260- // }
261- // }
262- // class LineLiveCommentProvider : ICommentProvider
263- // {
264- // private bool _canConnect;
265- // public bool CanConnect
266- // {
267- // get { return _canConnect; }
268- // set
269- // {
270- // if (_canConnect == value)
271- // return;
272- // _canConnect = value;
273- // CanConnectChanged?.Invoke(this, EventArgs.Empty);
274- // }
275- // }
276-
277- // private bool _canDisconnect;
278- // public bool CanDisconnect
279- // {
280- // get { return _canDisconnect; }
281- // set
282- // {
283- // if (_canDisconnect == value)
284- // return;
285- // _canDisconnect = value;
286- // CanDisconnectChanged?.Invoke(this, EventArgs.Empty);
287- // }
288- // }
289- // public event EventHandler<List<ICommentViewModel>> InitialCommentsReceived;
290- // public event EventHandler<ICommentViewModel> CommentReceived;
291- // public event EventHandler<IMetadata> MetadataUpdated;
292- // public event EventHandler CanConnectChanged;
293- // public event EventHandler CanDisconnectChanged;
294-
295- // private string GetChannelName(string input)
296- // {
297- // return Tools.GetChannelName(input);
298- // }
299- // private string _channelName;
300- // private MessageProvider _provider;
301- // //private CookieContainer _cc;
302- // public async Task ConnectAsync(string input, IBrowserProfile browserProfile)
303- // {
304- // CanConnect = false;
305- // CanDisconnect = true;
306- // try
307- // {
308- // _channelName = GetChannelName(input);
309- // var cc = new CookieContainer();
310-
311- // try
312- // {
313- // var cookies = browserProfile.GetCookieCollection("twitch.tv");
314- // cc.Add(cookies);
315- // }
316- // catch (Exception ex)
317- // {
318- // _logger.LogException(ex);
319- // }
320- // _me = null;
321- // try
322- // {
323- // _me = await API.GetMeAsync(_server, cc);
324- // }
325- // catch (NotLoggedInException) { }
326- // catch (Exception ex)
327- // {
328- // _logger.LogException(ex);
329- // }
330- // if (_me != null)
331- // {
332- // _emotIcons = await API.GetEmotIcons(_server, _me.Id, cc);
333- // }
334-
335-
336- // _provider = new MessageProvider();
337- // _provider.Opened += Provider_Opened;
338- // _provider.Received += Provider_Received;
339- // await _provider.ReceiveAsync();
340- // }
341- // finally
342- // {
343- // CanConnect = true;
344- // CanDisconnect = false;
345- // }
346- // }
347- // IMe _me;
348- // LowObject.Emoticons _emotIcons;
349- // private async void Provider_Received(object sender, Result e)
350- // {
351- // var result = e;
352- // switch (result.Command)
353- // {
354- // case "PING":
355- // await _provider.SendAsync("PONG");
356- // break;
357- // case "GLOBALUSERSTATE":
358- // break;
359- // case "PRIVMSG":
360- // {
361- // var commentData = new CommentData(result);
362- // var user = _userStore.GetUser(commentData.UserId);
363- // if (!_userCommentDict.TryGetValue(user, out ObservableCollection<LineLiveCommentViewModel> userComments))
364- // {
365- // userComments = new ObservableCollection<LineLiveCommentViewModel>();
366- // _userCommentDict.Add(user, userComments);
367- // }
368- // var isFirstComment = userComments.Count == 0;
369- // var cvm = new LineLiveCommentViewModel(_options, _siteOptions, commentData, _emotIcons, isFirstComment, this, user);
370- // await _dispatcher.BeginInvoke((Action)(() =>
371- // {
372- // userComments.Add(cvm);
373- // }));
374- // CommentReceived?.Invoke(this, cvm);
375- // }
376- // break;
377- // default:
378- // Debug.WriteLine($"LineLive unknown command={result.Command}");
379- // var info = new InfoCommentViewModel(_options, result.Raw, InfoType.Debug);
380- // CommentReceived?.Invoke(this, info);
381- // break;
382- // }
383- // }
384-
385- // private async void Provider_Opened(object sender, EventArgs e)
386- // {
387- // try
388- // {
389- // if (IsLoggedIn())
390- // {
391- // await _provider.SendAsync("CAP REQ :twitch.tv/tags twitch.tv/commands");
392- // await _provider.SendAsync($"PASS oauth:{_me.ChatOauthToken}");
393- // await _provider.SendAsync($"NICK {_me.Name}");
394- // await _provider.SendAsync($"USER {_me.Name} 8 * :{_me.Name}");
395- // }
396- // else
397- // {
398- // var name = Tools.GetRandomGuestUsername();
399- // await _provider.SendAsync("CAP REQ :twitch.tv/tags twitch.tv/commands");
400- // await _provider.SendAsync($"PASS SCHMOOPIIE");
401- // await _provider.SendAsync($"NICK {name}");
402- // await _provider.SendAsync($"USER {name} 8 * :{name}");
403- // }
404- // await _provider.SendAsync($"JOIN " + _channelName);
405- // }
406- // catch (Exception ex)
407- // {
408- // _logger.LogException(ex);
409- // CommentReceived?.Invoke(this, new InfoCommentViewModel(_options, ""));
410- // }
411- // }
412- // private bool IsLoggedIn()
413- // {
414- // return _me != null;
415- // }
416-
417- // public void Disconnect()
418- // {
419- // _provider.Disconnect();
420- // }
421-
422- // public IEnumerable<ICommentViewModel> GetUserComments(IUser user)
423- // {
424- // var comments = _userCommentDict[user];
425- // return comments;
426- // }
427-
428- // public async Task PostCommentAsync(string text)
429- // {
430- // var s = $"PRIVMSG {_channelName} :{text}";
431- // await Task.FromResult<object>(null);
432- // }
433- // private readonly Dictionary<IUser, ObservableCollection<LineLiveCommentViewModel>> _userCommentDict = new Dictionary<IUser, ObservableCollection<LineLiveCommentViewModel>>();
434- // private readonly IDataServer _server;
435- // private readonly ILogger _logger;
436- // private readonly ICommentOptions _options;
437- // private readonly LineLiveSiteOptions _siteOptions;
438- // private readonly IUserStore _userStore;
439- // private readonly Dispatcher _dispatcher;
440- // public LineLiveCommentProvider(IDataServer server, ILogger logger, ICommentOptions options, LineLiveSiteOptions siteOptions, IUserStore userStore, Dispatcher dispacher)
441- // {
442- // _server = server;
443- // _logger = logger;
444- // _options = options;
445- // _siteOptions = siteOptions;
446- // _userStore = userStore;
447- // _dispatcher = dispacher;
448-
449- // CanConnect = true;
450- // CanDisconnect = false;
451- // }
452- // }
453- // public class LineLiveSiteContext : ISiteContext
454- // {
455- // public Guid Guid => new Guid("22F7824A-EA1B-411E-85CA-6C9E6BE94E39");
456-
457- // public string DisplayName => "LineLive";
458-
459- // public IOptionsTabPage TabPanel
460- // {
461- // get
462- // {
463- // var panel = new TabPagePanel();
464- // panel.SetViewModel(new LineLiveSiteOptionsViewModel(_siteOptions));
465- // return new LineLiveOptionsTabPage(DisplayName, panel);
466- // }
467- // }
468-
469- // public ICommentProvider CreateCommentProvider()
470- // {
471- // return new LineLiveCommentProvider(new LineLiveServer(), _logger, _options, _siteOptions, _userStore, _dispatcher);
472- // }
473- // private LineLiveSiteOptions _siteOptions;
474- // public void LoadOptions(string path, IIo io)
475- // {
476- // _siteOptions = new LineLiveSiteOptions();
477- // try
478- // {
479- // var s = io.ReadFile(path);
480-
481- // _siteOptions.Deserialize(s);
482- // }
483- // catch (Exception ex)
484- // {
485- // Debug.WriteLine(ex.Message);
486- // _logger.LogException(ex, "", $"path={path}");
487- // }
488- // }
489-
490- // public void SaveOptions(string path, IIo io)
491- // {
492- // try
493- // {
494- // var s = _siteOptions.Serialize();
495- // io.WriteFile(path, s);
496- // }
497- // catch (Exception ex)
498- // {
499- // Debug.WriteLine(ex.Message);
500- // _logger.LogException(ex, "", $"path={path}");
501- // }
502- // }
503- // public bool IsValidInput(string input)
504- // {
505- // //チャンネル名だけ来られても他のサイトのものの可能性があるからfalse
506- // //"twitch.tv/"の後に文字列があったらtrueとする。
507- // var b = Regex.IsMatch(input, "twitch\\.tv/[a-zA-Z0-9_]+");
508- // return b;
509- // }
510-
511- // public UserControl GetCommentPostPanel(ICommentProvider commentProvider)
512- // {
513- // return null;
514- // }
515-
516- // private readonly ICommentOptions _options;
517- // private readonly ILogger _logger;
518- // private readonly IUserStore _userStore;
519- // private readonly Dispatcher _dispatcher;
520- // public LineLiveSiteContext(ICommentOptions options, ILogger logger, IUserStore userStore, Dispatcher dispatcher)
521- // {
522- // _options = options;
523- // _logger = logger;
524- // _userStore = userStore;
525- // _dispatcher = dispatcher;
526- // }
527- // }
528- //}
0 commit comments