Example #1
0
        private List<MediaDB> get(string GroupID, string MediaID, string token)
        {
            List<MediaDB> media = new List<MediaDB> { };
            XDocument xml = null;
            try
            {
                string captcha = "";
                Refresh: xml = XDocument.Load("https://api.vk.com/method/wall.getById.xml?posts=" + GroupID + "_" + MediaID + captcha + "&access_token=" + token);
                foreach (XElement el in xml.Root.Elements())
                {
                    if (el.Name.ToString() == "captcha_img")
                    {
                        Console.WriteLine("Разгадываем капчу в PhotoEdit.cs");
                        captcha = new Antigate().get(el.Value);
                        goto Refresh;
                    }
                    else if (el.Name.ToString() == "post")
                    {
                        foreach (XElement el_post in el.Elements())
                        {
                            if (el_post.Name == "attachments")
                            {
                                foreach (XElement el_attachments in el_post.Elements())
                                {
                                    foreach (XElement el_attachment in el_attachments.Elements())
                                    {
                                        if (el_attachment.Name == "photo")
                                        {
                                            MediaDB tmp = new MediaDB();
                                            foreach (XElement el_photo in el_attachment.Elements())
                                            {
                                                switch (el_photo.Name.ToString())
                                                {
                                                    case "pid": tmp.pid = el_photo.Value; break;
                                                    case "owner_id": tmp.owner_id = el_photo.Value; break;
                                                }
                                            }
                                            media.Add(tmp); tmp = null;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                captcha = null;
            }
            catch (Exception e)
            {
                if (e != null)
                    Console.WriteLine("Ошибка в PhotoEdit.cs, код ошибки: {1}{0}{1}{1}", e, Environment.NewLine);
            }

            //Воврат результата
            GroupID = null; MediaID = null; xml = null;
            return media;
        }
Example #2
0
        private MediaDB get(string video_id, string owner_id, string token)
        {
            MediaDB media = new MediaDB();
            XDocument xml = null;
            try
            {
                string captcha = "";
                Refresh: xml = XDocument.Load("https://api.vk.com/method/video.get.xml?owner_id=" + owner_id + "&videos=" + owner_id + "_" + video_id + "&access_token=" + token);
                foreach (XElement el in xml.Root.Elements())
                {
                    if (el.Name.ToString() == "captcha_img")
                    {
                        Console.WriteLine("Разгадываем капчу в VideoEdit.cs");
                        captcha = new Antigate().get(el.Value);
                        goto Refresh;
                    }
                    else if (el.Name.ToString().ToLower().Trim() == "video")
                    {
                        foreach (XElement el_video in el.Elements())
                        {
                            switch (el_video.Name.ToString().ToLower().Trim())
                            {
                                case "title": media.title = (el_video.Value.Trim() == "" ? null : el_video.Value); break;
                                case "description": media.description = (el_video.Value.Trim() == "" ? null : el_video.Value); break;
                            }
                        }

                        //Проверка на спам
                        if (media.title != null && new CheckSpam().get(media.title, null))
                        {
                            media.title = null;
                        }
                        if (media.description != null && new CheckSpam().get(media.description, null))
                        {
                            media.description = null;
                        }
                    }
                }
                captcha = null;
            }
            catch { }

            //Воврат результата
            owner_id = null; video_id = null; xml = null;
            return media;
        }
Example #3
0
File: Program.cs Project: XCVG/XSMP
        static void Main(string[] args)
        {
            Console.WriteLine($"Starting {ProductNameString}");

            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(HandleExternalExit);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(HandleUnhandledException);

            //portable mode handling
            CheckPortableMode(args);

            SetupFolders();
            LoadUserConfig();

            //port override arg handling
            CheckPortOverride(args);

            MediaDB       mediaDatabase = new MediaDB();
            APIController apiController = new APIController(new APISurface(mediaDatabase));
            RESTServer    restServer    = new RESTServer(apiController);

            IsRunning = true;

            //argument commands handling
            if (args.Contains("-rebuild"))
            {
                mediaDatabase.StartRebuild();
            }

            if (args.Contains("-flushcache"))
            {
                MediaTranscoder.FlushCache();
            }

            while (IsRunning)
            {
                Thread.Sleep(10);
                //TODO poll components?
            }

            Console.WriteLine("Ending XSMP");

            restServer.Dispose();
            mediaDatabase.Dispose();
        }
Example #4
0
 //WIP constructor with pseudo-DI
 public APISurface(MediaDB mediaDatabase)
 {
     MediaDatabase = mediaDatabase;
 }