| 1 |
using System; |
| 2 |
using System.Collections.Generic; |
| 3 |
using System.Windows.Forms; |
| 4 |
using System.Xml.Serialization; |
| 5 |
using System.IO; |
| 6 |
|
| 7 |
namespace Aqua877.WinApp.IronLivetube |
| 8 |
{ |
| 9 |
public static class GlobalValues |
| 10 |
{ |
| 11 |
public static event Action OnCallCleanCachesCalled; |
| 12 |
public const string LiveUrlPattern = @"http://(tes01.|h.|)livetube\.cc/(.+?)"; |
| 13 |
public static string StreamIDPattern = @"[a-z0-9]{13}"; |
| 14 |
public const string GetStreamIDPattern = @"http://(?:(?:(?:h|tes01|large03|large04|large05)\.|))livetube.cc/stream/([a-z0-9]{13})"; |
| 15 |
public const string ExtractCommentDataPattern = |
| 16 |
@"<div style=""background-color: #eee;""> |
| 17 |
<div style=""margin-top: 6px;"">(<span style=""float:right;font-size:60%;font-style:italic;"">(.*?)</span>|) |
| 18 |
(<img src=""(.*?)"" width=""(.*?)"" height=""(.*?)"" align=""left"" />|) |
| 19 |
(.*?) : (<a href=""/(.*?)""><span style=""font-size:1em;color:green; font-weight:bolder;"">(.*?)(<span style=""color:blue;"">(.*?)</span>|)</span></a>|(.*?)|) <span style="""">(.*?)</span><br /> |
| 20 |
<span style=""font-weight:bold;margin-bottom:0px; padding-bottom:0px;"">(.*?)</span><br clear=""left"" /> |
| 21 |
</div> |
| 22 |
</div>"; |
| 23 |
public const string BitLyUserName = "ironlivetube"; |
| 24 |
public const string BitLyApiKey = "R_f76fa9cb2519f87a22ffb34e7c59b004"; |
| 25 |
public const string PTlApiKey = "c371efed93161dd07388bd0ea671d849abdf7834"; |
| 26 |
|
| 27 |
public static readonly string SettingFilePath = Environment.CurrentDirectory + "\\IronLivetube.config.xml"; |
| 28 |
public static readonly string[] SupportedShortenServices = { "bit.ly", "j.mp", "is.gd", "ux.nu", "p.tl" }; |
| 29 |
public static Settings Setting = new Settings(); |
| 30 |
public static int CachingComments = 0; |
| 31 |
public static int CachingThumbnails = 0; |
| 32 |
public static bool RestartProgramTrigger = false; |
| 33 |
|
| 34 |
public static void LoadSettings() |
| 35 |
{ |
| 36 |
if (File.Exists(SettingFilePath)) |
| 37 |
{ |
| 38 |
using (var stream = new FileStream(SettingFilePath, FileMode.Open)) |
| 39 |
{ |
| 40 |
try |
| 41 |
{ |
| 42 |
var deserializer = new XmlSerializer(typeof(Settings)); |
| 43 |
Setting = deserializer.Deserialize(stream) as Settings; |
| 44 |
} |
| 45 |
catch |
| 46 |
{ |
| 47 |
#warning TODO : エラーロギング |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
public static void SaveSettings() |
| 54 |
{ |
| 55 |
using (var stream = new FileStream(SettingFilePath, FileMode.Create)) |
| 56 |
{ |
| 57 |
var serializer = new XmlSerializer(typeof(Settings)); |
| 58 |
serializer.Serialize(stream, Setting); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
public static void CallCleanCaches() |
| 63 |
{ |
| 64 |
if (OnCallCleanCachesCalled != null) |
| 65 |
{ |
| 66 |
OnCallCleanCachesCalled(); |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
} |