示例#1
0
 public UI_input(LSSettings.LSMeta meta, List <LSSettings.LSMeta> metas)
 {
     InitializeComponent();
     textBox1.Text = meta.tit;
     this.metas    = metas;
     this.meta     = meta;
     wasAdded      = true;
 }
示例#2
0
 public UI_input(LSSettings.LSMeta meta, List<LSSettings.LSMeta> metas)
 {
     InitializeComponent();
     textBox1.Text = meta.tit;
     this.metas = metas;
     this.meta = meta;
     wasAdded = true;
 }
示例#3
0
        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", "(this really should not happen)"));
            }
            GroupCollection r;

            try
            {
                r = Regex.Match(raw, m.ptn, RegexOptions.Singleline).Groups;
            }
            catch
            {
                return(new LSTD(false, "(bad regex)", "The Pattern in this profile has a typo,\nor is otherwise broken. Call techsupport.\n\nPattern: " + m.ptn));
            }
            if (r.Count > m.yi.max)
            {
                try
                {
                    //string ret = r[m.grp].Value.Trim(' ', '\t', '\r', '\n'); // you can never be too sure
                    string ret = m.yi.format(r);
                    if (m.urldecode)
                    {
                        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(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)
                            )));
        }
示例#4
0
        void feeder()
        {
            Est[] est =
            {
                settings.mp3.enabled ? new Est("",  settings.mp3) : null,
                settings.ogg.enabled ? new Est("",  settings.ogg) : null,
                settings.opus.enabled ? new Est("", settings.opus) : null,
            };
            Logger.tag.a("active");
            bouncer = settings.meta.bnc;
            lastTag = null;
            while (!quitting)
            {
                LSSettings.LSMeta m = settings.meta;
                tag    = settings.tagAuto ? get(m, false) : manual;
                manual = tag;
                if (!string.IsNullOrEmpty(tag.tag) && tag.ok)
                {
                    long now = DateTime.UtcNow.Ticks / 10000;
                    if (lastTag != tag.tag)
                    {
                        lastTag = tag.tag;
                        bouncer = settings.meta.bnc;
                    }
                    if (--bouncer < 0)
                    {
                        try
                        {
                            var buf = System.Text.Encoding.UTF8.GetBytes(tag.tag + "\n");
                            using (var fs = new System.IO.FileStream(Program.tools + "tags.txt", System.IO.FileMode.Create))
                                fs.Write(buf, 0, buf.Length);
                        }
                        catch { }

                        foreach (Est e in est)
                        {
                            if (e != null &&
                                streaming &&
                                e.tag != tag.tag &&
                                e.enc.FIXME_kbps > 0)
                            {
                                e.tag = tag.tag;
                                sendTags(e);
                            }
                        }
                    }
                }
                System.Threading.Thread.Sleep(settings.meta.freq);
            }
            Logger.tag.a("disposed");
        }
示例#5
0
 void feeder()
 {
     Est[] est =
     {
         settings.mp3.enabled ? new Est("", settings.mp3) : null,
         settings.ogg.enabled ? new Est("", settings.ogg) : null,
     };
     Logger.tag.a("active");
     bouncer = settings.meta.bnc;
     lastTag = null;
     while (!quitting)
     {
         LSSettings.LSMeta m = settings.meta;
         tag    = settings.tagAuto ? get(m, false) : manual;
         manual = tag;
         if (!string.IsNullOrEmpty(tag.tag) && tag.ok)
         {
             long now = DateTime.UtcNow.Ticks / 10000;
             if (lastTag != tag.tag)
             {
                 lastTag = tag.tag;
                 bouncer = settings.meta.bnc;
             }
             if (--bouncer < 0)
             {
                 foreach (Est e in est)
                 {
                     if (e != null &&
                         e.tag != tag.tag &&
                         e.enc.FIXME_kbps > 0)
                     {
                         e.tag = tag.tag;
                         sendTags(e);
                     }
                 }
             }
         }
         System.Threading.Thread.Sleep(settings.meta.freq);
     }
     Logger.tag.a("disposed");
 }
示例#6
0
        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('*'))
                {
                    raw = WinapiShit.getWinText(new IntPtr(Convert.ToInt32(m.src.Split('*')[1], 16)));
                }
                if (string.IsNullOrEmpty(raw))
                {
                    Process[] proc = Process.GetProcessesByName(m.src.Split('*')[0]);
                    if (proc.Length < 1)
                    {
                        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)", "The media player  «" + m.src + "»  could not be found!\n\nAre you sure that it is running?"));
                }
                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, "SUCCESS") : get(m, ret));
                }
                catch
                {
                    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)
            {
                byte[] b;
                try
                {
                    b = new System.Net.WebClient().DownloadData(m.src);
                    try
                    {
                        string ret = m.enc.GetString(b);
                        return(getRaw ? new LSTD(true, ret, "SUCCESS") : get(m, ret));
                    }
                    catch
                    {
                        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)", "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)
            {
                // this is the fun one
                Process[] proc = Process.GetProcessesByName(m.src);
                if (proc.Length < 1)
                {
                    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
                {
                    mem = new LSMem(proc[0]);
                }
                catch
                {
                    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
                {
                    string        ret      = "";
                    string        lpm      = "";
                    bool          hadError = false;
                    ProcessModule pm       = null;
                    byte[]        raw      = new byte[1024];
                    string[]      ad       = m.ptn.Split(' ');
                    for (int a = 0; a < ad.Length; a++)
                    {
                        string arg = ad[a].Trim(',', ' ');
                        IntPtr ofs = IntPtr.Zero;
                        if (arg.Contains('+'))
                        {
                            string[] args = arg.Split('+');
                            if (args[0] != lpm)
                            {
                                pm  = null;
                                lpm = null;
                                foreach (ProcessModule mod in proc[0].Modules)
                                {
                                    if (mod.ModuleName == args[0])
                                    //if (mod.FileName.EndsWith("\\iTunes.dll"))
                                    {
                                        pm  = mod;
                                        lpm = pm.ModuleName;
                                        ofs = pm.BaseAddress;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                ofs = pm.BaseAddress;
                            }
                            arg = args[1];
                        }
                        int[] steps = new int[0];
                        if (arg.Contains('*'))
                        {
                            string[] args = arg.Split('*');
                            steps = new int[args.Length - 1];
                            for (int b = 1; b < args.Length; b++)
                            {
                                steps[b - 1] = Convert.ToInt32(args[b], 16);
                            }
                            arg = args[0];
                        }
                        ofs += Convert.ToInt32(arg, 16);
                        ret += a == 0 || ret.Length == 0 ? "" : " - ";
                        int len = mem.read(ofs, raw, steps);
                        if (len < 0)
                        {
                            ret     += "(read error)";
                            hadError = true;
                        }
                        else if (len > 0)
                        {
                            ret += m.enc.GetString(raw);
                            int i = ret.IndexOf('\0');
                            if (i >= 0)
                            {
                                ret = ret.Substring(0, i);
                            }
                        }
                    }
                    return(new LSTD(!hadError, ret, hadError ? "Could not peek into the target application.\n\nThe media player is likely a 32bit process, while\nLoopstream is running in 64bit mode\n(or the other way around)." : "SUCCESS"));
                }
                catch
                {
                    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."));
                }
            }
            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?"));
            }
        }
示例#7
0
        private void gTagimport_Click(object sender, EventArgs e)
        {
            string key = Clipboard.GetText();
            if (!key.Contains("#gz#"))
            {
                if (key.ToLower().Contains("bpaste.net"))
                {
                    // http://bpaste.net/show/PNaO8zoBtZdPRv8NLoNs/
                    // http://bpaste.net/raw/PNaO8zoBtZdPRv8NLoNs/
                    var r = Regex.Match(key, "(.*[^a-zA-Z0-9]|^)bpaste.net/[^/]*/([^/]*)(/|$)", RegexOptions.IgnoreCase).Groups;
                    if (r.Count > 2)
                    {
                        key = new System.Net.WebClient().DownloadString("http://bpaste.net/raw/" + r[2].Value + "/");
                    }
                }
                else if (key.ToLower().Contains("pastebin.com"))
                {
                    // http://pastebin.com/gbwsufzV
                    // http://pastebin.com/raw.php?i=gbwsufzV
                    var r = Regex.Match(key, ".*(.*[^a-zA-Z0-9]|^)pastebin.com.*[/=]([^/=]*)$", RegexOptions.IgnoreCase).Groups;
                    if (r.Count > 2)
                    {
                        key = new System.Net.WebClient().DownloadString("http://pastebin.com/raw.php?i=" + r[2].Value + "/");
                    }
                }
            }
            try
            {
                int i = key.IndexOf("gz#");
                int j = key.IndexOf("#", i + 4);
                if (i < 0 || j < 0) throw new Exception();
                i += 3;
                key = key.Substring(i, j - i);
            }
            catch
            {
                MessageBox.Show(
                    "Padding error\n\n" +
                    "Sorry, but the share-key is invalid.");
                return;
            }
            try
            {
                key = Z.gzd(key);
            }
            catch
            {
                MessageBox.Show(
                    "Decoder error\n\n" +
                    "Sorry, but the share-key is invalid.");
                return;
            }
            LSSettings.LSMeta fds = new LSSettings.LSMeta();
            try
            {
                string chrome = serialize(fds);
                string chrome1 = chrome.Substring(0, chrome.IndexOf('>') + 1);
                string chrome2 = chrome.Substring(chrome.LastIndexOf('<'));
                key = chrome1 + key + chrome2;

                var sr = new System.IO.StringReader(key);
                var ds = new System.Xml.Serialization.XmlSerializer(typeof(LSSettings.LSMeta));
                fds = (LSSettings.LSMeta)ds.Deserialize(sr);
            }
            catch
            {
                MessageBox.Show(
                    "Serializer error\n\n" +
                    "Sorry, but the share-key is invalid:\n\n" +
                    key);
                return;
            }
            UI_input inp = new UI_input(fds, settings.metas);
            inp.ShowDialog();
            if (inp.wasAdded)
            {
                loadMetaReader(true);
                gMeta.SelectedItem = settings.metas[settings.metas.Count - 1];
            }
        }