Skip to content

Commit

Permalink
v.1.3.6.7, 2014-01-24, 02:51:54
Browse files Browse the repository at this point in the history
+ Descriptions for tag reader profiles
  • Loading branch information
9001 committed Oct 12, 2015
1 parent 6475cd6 commit 71896c8
Show file tree
Hide file tree
Showing 13 changed files with 1,008 additions and 437 deletions.
232 changes: 203 additions & 29 deletions Loopstream/LSSettings.cs

Large diffs are not rendered by default.

129 changes: 91 additions & 38 deletions Loopstream/LSTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public LSTag(LSSettings set)
{
Logger.tag.a("init");

tag = new LSTD(false, "");
manual = new LSTD(false, "");
settings = set;
quitting = false;
haveFailed = false;
latin1 = Encoding.GetEncoding("ISO_8859-1");
manual = new LSTD(false, "", "STILL_UNUSED");
tag = new LSTD(false, "", "STILL_UNUSED");

auth = string.Format("{0}:{1}", settings.user, settings.pass);
auth = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(auth));
Expand All @@ -43,13 +43,43 @@ public void Dispose()
public void set(string str)
{
Logger.tag.a("set " + str);
manual = new LSTD(true, str);
manual = new LSTD(true, str, "MANUALLY_APPLIED");
}

public static LSTD get(LSSettings.LSMeta m, bool getRaw)
{
if (m.reader == LSSettings.LSMeta.Reader.WindowCaption)
{
if (m.src.Trim() == "*")
{
int myId = System.Diagnostics.Process.GetCurrentProcess().Id;
int[] handles = EnumHandles.Run();
foreach (int hWnd in handles)
{
IntPtr ptr = new IntPtr(hWnd);
uint proc = WinapiShit.getProcId(ptr);
if (proc <= 1) continue;
if (proc == myId) continue;
string text = WinapiShit.getWinText(ptr);
if (string.IsNullOrEmpty(text)) continue;

//gList.Items.Add("<" + hWnd + "> // <" + proc + "> // <" + text + ">");
LSTD td = get(m, text);
if (td.ok)
{
return td;
}
}
return new LSTD(false, "(no hits)",
"The pattern in this profile did not match any of your windows.\n" +
"\n" +
"If you are using an in-browser media player (cloud service),\n" +
"make sure the media player is in a dedicated browser window.\n" +
"\n" +
"(you must construct additional windows)");
}


string raw = null;
if (m.src.Contains('*'))
{
Expand All @@ -60,26 +90,26 @@ public static LSTD get(LSSettings.LSMeta m, bool getRaw)
Process[] proc = Process.GetProcessesByName(m.src.Split('*')[0]);
if (proc.Length < 1)
{
return new LSTD(false, "(no such process)");
return new LSTD(false, "(no such process)", "The media player «" + m.src + "» could not be found!\n\nAre you sure that it is running?");
}
raw = proc[0].MainWindowTitle;
}
if (string.IsNullOrEmpty(raw))
{
return new LSTD(false, "(no such target)");
return new LSTD(false, "(no such target)", "The media player «" + m.src + "» could not be found!\n\nAre you sure that it is running?");
}
return getRaw ? new LSTD(true, raw) : get(m, raw);
return getRaw ? new LSTD(true, raw, "SUCCESS") : get(m, raw);
}
if (m.reader == LSSettings.LSMeta.Reader.File)
{
try
{
string ret = System.IO.File.ReadAllText(m.src, m.enc);
return getRaw ? new LSTD(true, ret) : get(m, ret);
return getRaw ? new LSTD(true, ret, "SUCCESS") : get(m, ret);
}
catch
{
return new LSTD(false, "(file read failure)");
return new LSTD(false, "(file read failure)", "Something went wrong while reading the provided file.\nAre you sure it exists?\n\nPath: " + m.src);
}
}
if (m.reader == LSSettings.LSMeta.Reader.Website)
Expand All @@ -91,16 +121,16 @@ public static LSTD get(LSSettings.LSMeta m, bool getRaw)
try
{
string ret = m.enc.GetString(b);
return getRaw ? new LSTD(true, ret) : get(m, ret);
return getRaw ? new LSTD(true, ret, "SUCCESS") : get(m, ret);
}
catch
{
return new LSTD(false, "(web decode failure)");
return new LSTD(false, "(web decode failure)", "I failed to unpack the data from the web server.\nMaybe incorrect address?\n\nLink: " + m.src);
}
}
catch
{
return new LSTD(false, "(web request failure)");
return new LSTD(false, "(web request failure)", "I failed to download the data from the web server.\nMaybe it is down?\n\nLink: " + m.src);
}
}
if (m.reader == LSSettings.LSMeta.Reader.ProcessMemory)
Expand All @@ -109,7 +139,7 @@ public static LSTD get(LSSettings.LSMeta m, bool getRaw)
Process[] proc = Process.GetProcessesByName(m.src);
if (proc.Length < 1)
{
return new LSTD(false, "(no such process)");
return new LSTD(false, "(no such process)", "The media player «" + m.src + "» could not be found!\n\nAre you sure that it is running?");
}
LSMem mem;
try
Expand All @@ -118,7 +148,7 @@ public static LSTD get(LSSettings.LSMeta m, bool getRaw)
}
catch
{
return new LSTD(false, "(poke failure)");
return new LSTD(false, "(poke failure)", "I failed to harvest the metadata from inside «" + m.src + "»...\n\nMaybe system permissions blocked the request?\nTry running Loopstream as administrator.");
}
try
{
Expand Down Expand Up @@ -184,22 +214,29 @@ public static LSTD get(LSSettings.LSMeta m, bool getRaw)
}
}
}
return new LSTD(true, ret);
return new LSTD(true, ret, "SUCCESS");
}
catch
{
return new LSTD(false, "(peek failure)");
return new LSTD(false, "(peek failure)", "I failed to harvest the metadata from inside «" + m.src + "»...\n\nThis is probably a bug in Loopstream, but it could\nalso be system permissions getting in the way.\n\nYou could try running Loopstream as Administrator.");
}
}
return new LSTD(false, "(unexpected failure)");
try
{
return new LSTD(false, "(unexpected metadata reader)", "You somehow managed to select a\nMetaReader which does not exist:\n\n «" + m.reader.ToString() + "»");
}
catch
{
return new LSTD(false, "(unexpected metadata reader)", "You somehow managed to select a\nMetaReader which does not exist. How?");
}
}

public static LSTD get(LSSettings.LSMeta m, string raw)
{
Logger.tag.a("get " + raw);
if (m.reader == LSSettings.LSMeta.Reader.ProcessMemory)
{
return new LSTD(false, "if you are seeing this, go whine to ed");
return new LSTD(false, "if you are seeing this, go whine to ed", "(this really should not happen)");
}
GroupCollection r;
try
Expand All @@ -208,32 +245,46 @@ public static LSTD get(LSSettings.LSMeta m, string raw)
}
catch
{
return new LSTD(false, "(bad regex)");
return new LSTD(false, "(bad regex)", "The Pattern in this profile has a typo,\nor is otherwise broken. Call techsupport.\n\nPattern: " + m.ptn);
}
try
if (r.Count > m.grp)
{
string ret = r[m.grp].Value.Trim(' ', '\t', '\r', '\n'); // you can never be too sure
if (m.urldecode)
try
{
string[] sanitize = {
"&quot;", "\"",
"&apos;", "'",
"&#039;", "'",
"&lt;", "<",
"&gt;", ">",
"&amp;", "&"
};
for (int a = 0; a < sanitize.Length; a += 2)
string ret = r[m.grp].Value.Trim(' ', '\t', '\r', '\n'); // you can never be too sure
if (m.urldecode)
{
ret = ret.Replace(sanitize[a], sanitize[a + 1]);
string[] sanitize = {
"&quot;", "\"",
"&apos;", "'",
"&#039;", "'",
"&lt;", "<",
"&gt;", ">",
"&amp;", "&"
};
for (int a = 0; a < sanitize.Length; a += 2)
{
ret = ret.Replace(sanitize[a], sanitize[a + 1]);
}
}
return new LSTD(true, ret, "SUCCESS");
}
catch
{
}
return new LSTD(true, ret);
}
catch
{
return new LSTD(false, "(no match)");
}
return new LSTD(false, "(no match)",
(
m.reader == LSSettings.LSMeta.Reader.WindowCaption ? "The window title of «" + m.src + "» " :
m.reader == LSSettings.LSMeta.Reader.Website ? "The contents of the provided website" :
m.reader == LSSettings.LSMeta.Reader.File ? "The contents in the provided file" :
"(something is seriously wrong)"
) +
" was not possible to\nunderstand using the Pattern specified in this profile." +
(
m.reader != LSSettings.LSMeta.Reader.WindowCaption ?
"" : ("\n\nI tried to read from this: " + m.src)
));
}

void feeder()
Expand Down Expand Up @@ -308,7 +359,7 @@ void sendTags(Est est)
catch
{
Logger.tag.a(est.enc.ext + " send fail");
tag = new LSTD(false, "Meta-fail " + est.enc.ext);
tag = new LSTD(false, "Meta-fail " + est.enc.ext, "(unknown error)");
}
}

Expand All @@ -327,8 +378,10 @@ public class LSTD
{
public bool ok;
public string tag;
public LSTD(bool o, string t)
public string error;
public LSTD(bool o, string t, string e)
{
error = e;
tag = t;
ok = o;
}
Expand Down
1 change: 1 addition & 0 deletions Loopstream/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static void Main(string[] args)
rnd = new Random();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new UI_Winlist());
Application.Run(new Home());
}

Expand Down
4 changes: 2 additions & 2 deletions Loopstream/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.6.4")]
[assembly: AssemblyFileVersion("1.3.6.4")]
[assembly: AssemblyVersion("1.3.6.7")]
[assembly: AssemblyFileVersion("1.3.6.7")]
Loading

0 comments on commit 71896c8

Please sign in to comment.