Exemplo n.º 1
0
        private static string[] _checkContent(OriginalPost post)
        {
            string[] _res = { "", "" };
            bool     _hasCat = false; bool _hasDog = false; bool _hasAnimal = false;
            string   _cat = ""; string _dog = "";

            _cat    = Tools.ContainsString(post.Title, catWords);
            _dog    = Tools.ContainsString(post.Title, dogWords);
            _hasCat = !_cat.Equals("=(");
            _hasDog = !_dog.Equals("=(");
            if (_hasCat && _hasDog)
            {
                _res[0] = "CAT_DOG"; _res[1] = _cat + "_" + _dog; return(_res);
            }
            if (_hasCat)
            {
                _res[0] = "CAT"; _res[1] = _cat; return(_res);
            }
            if (_hasDog)
            {
                _res[0] = "DOG"; _res[1] = _dog; return(_res);
            }
            string _other = Tools.ContainsString(post.Title, animalWords);

            if (!_other.Equals("=("))
            {
                _res[0] = "ANIMAL"; _res[1] = _other; return(_res);
            }
            return(null);
        }
Exemplo n.º 2
0
 public static void Archive(OriginalPost post)
 {
     if (post.Site.Equals("www.reddit.com"))
     {
         _archiveRedditPost(post);
     }
 }
Exemplo n.º 3
0
        private static int _checkOCLevel(OriginalPost post)
        {
            string _ocWORDS = Tools.ContainsString(post.Title, OCWords);

            if (!_ocWORDS.Equals("=("))
            {
                return(5);
            }
            return(0);
        }
Exemplo n.º 4
0
        private static void _archiveRedditPost(OriginalPost post)
        {
            AutoMeta _meta = new AutoMeta();

            _meta.PostID = post.ID;
            string[] _content = _checkContent(post); if (_content != null)
            {
                _meta.ContentFromTitle = _content[0]; _meta.ContentSubtype = _content[1]; _meta.ContentConfidence = 5;
            }
            _meta.OCConfidence += _checkOCLevel(post);
            _meta.Save();
        }
Exemplo n.º 5
0
        public static OriginalPostGroup GetListToRank_ONLYIMUGR(string orderby, int count)
        {
            //for now order by date always!!
            OriginalPostGroup _res  = new OriginalPostGroup();
            ArrayList         _list = new ArrayList();

            DBManager     dbm    = new DBManager("local");
            string        _query = "select top " + count + " _ID from CS_OriginalPost where _ID not in (select PostID from CS_ManualMeta) and FullURL like '%imgur.com%' order by _date asc";
            SqlDataReader _sqr   = dbm.ExecuteQuery(_query);
            int           i      = 0;

            while (_sqr.Read())
            {
                OriginalPost op = new OriginalPost(int.Parse(_sqr[0].ToString()));
                op.LocalIMGURL = "re_srcs" + op.LocalIMGURL.Split(new string[] { "re_srcs" }, StringSplitOptions.RemoveEmptyEntries)[1];
                op.LocalIMGURL = op.LocalIMGURL.Replace(".gif", ".mp4");
                _list.Add(op);
                i++;
            }
            _res.Kitties = (OriginalPost[])_list.ToArray(typeof(OriginalPost));
            return(_res);
        }
Exemplo n.º 6
0
        private static int _savePost(RedditSharp.Things.Post post)
        {
            if (IHasIt(post))
            {
                return(1);             //f**k it, cause I am too cool and I procedure
            }
            string       __root = Tools.GetRoot();
            OriginalPost op     = new OriginalPost();

            op.ContextURL  = "http://www.reddit.com/" + post.Permalink.ToString();
            op.Date        = post.Created;
            op.Description = post.SelfText;
            op.NLikes      = post.Upvotes - post.Downvotes;
            op.OPName      = post.AuthorName;
            op.OPUserLink  = "http://www.reddit.com/user/" + post.AuthorName;
            op.Site        = "www.reddit.com";
            op.Title       = post.Title;
            op.FUllURL     = post.Url.ToString();
            op.IDOnSource  = post.Id;
            op.Save();
            IMGURDec _dec;

            if (post.Url.ToString().IndexOf("imgur") >= 0)
            {
                try
                {
                    //is imgur
                    _dec = IMGURConsumer.GetImages(post.Url.ToString());
                }
                catch (Exception ex) { return(2); }
                if (_dec.IsAlbum)
                {
                    op.HasAlbum = true;
                    //ImageDesc[] _images= new ImageDesc[_dec.Titles.Length];
                    for (int i = 0; i < _dec.Titles.Length; i++)
                    {
                        ImageDesc _image = new ImageDesc();
                        _image              = new ImageDesc();
                        _image.ContextURL   = _dec.ContextURL;
                        _image.Description  = _dec.Descs[i];
                        _image.FileType     = _dec.FileTypes[i];
                        _image.FUllURL      = _dec.FullURLs[i];
                        _image.IMGURL       = _dec.FullURLs[i];
                        _image.LocalIMGURL  = __root + @"reddit\" + post.SubredditName + @"\imgur\" + _dec.FileNames[i];
                        _image.ParentPostID = op.ID;
                        _image.Site         = "www.imgur.com";
                        _image.Title        = _dec.Titles[i];
                        _image.Save();
                        Tools.DownloadFile(_image.FUllURL, _image.LocalIMGURL);
                    }
                }
                else
                {
                    op.HasAlbum = false;

                    op.Description = _dec.Descs[0];
                    op.FileType    = _dec.FileTypes[0];
                    op.IMGURL      = _dec.FullURLs[0];
                    op.LocalIMGURL = __root + @"reddit\" + post.SubredditName + @"\imgur\" + _dec.FileNames[0];
                }
            }
            else
            {
                //non-IMGUR
                string[] _ext2 = Tools.GetFileExtension(post.Url.ToString());

                op.HasAlbum    = false;
                op.Description = "NODESC";
                op.FileType    = _ext2[1];
                op.IMGURL      = post.Url.ToString();
                op.LocalIMGURL = __root + @"reddit\" + post.SubredditName + @"\else\" + _ext2[0] + _ext2[1];
            }

            if (op.IMGURL != null && op.LocalIMGURL != null)
            {
                op.ResourceError = Tools.DownloadFile(op.IMGURL, op.LocalIMGURL);
            }
            op.Save();
            MasterMind.Archive(op);
            return(0);
        }
Exemplo n.º 7
0
 private static bool IHasIt(RedditSharp.Things.Post post)
 {
     return(OriginalPost.rddt_IHazIt(post.Id));
 }