private async void DownloadBtn_Click(object sender, RoutedEventArgs e)
        {
            string     subRedditName = this.SubredditTBox.Text;
            PostStatus postStatus    = (PostStatus)this.PostStatusComboBox.SelectedItem;
            int        maxPosts      = Int32.Parse(PostCountTBox.Text);

            RedditRipper ripper    = new RedditRipper(subRedditName, postStatus, maxPosts);
            SubReddit    subReddit = await ripper.GetSubReddit();

            foreach (Post post in subReddit.Data.Posts)
            {
                DownloadItem item = new DownloadItem();
                item.Title = post.Data.Title;
                item.Url   = post.Data.Url;

                if (item.Url.Contains("gfycat.com"))
                {
                    item.Url = RedditAPI.utils.Utils.GetImageUrlFromGfycat(item.Url);
                }

                item.FileName = Web.utils.Utils.Instance.GetFileNameFromUrl(item.Url);
                item.FileName = string.IsNullOrEmpty(item.FileName) || string.IsNullOrWhiteSpace(item.FileName)
                    ? $"{item.Title}.png" : item.FileName;

                this.DownloadLogBox.Items.Add(item);

                Downloader downloader = new Downloader($"Downloads\\{subRedditName}\\{postStatus.ToString()}");
                downloader.DownloadAsync(item);
            }
        }
 public IActionResult ViewSubReddit(string subredditName)
 {
     try
     {
         SubReddit sub = redditDAL.ConvertToSubReddit(subredditName);
         return(View(sub));
     }
     catch (Exception)
     {
         return(RedirectToAction("ErrorSubReddit"));
     }
 }
示例#3
0
        public async Task <SubReddit> GetSubReddit()
        {
            string url  = Utils.BuildUrl(this.subReddit, this.postStatus, this.maxPosts);
            string json = await WebRequest.GetAsyncTask(url);

            SubReddit subReddit = SubReddit.ConvertToSubReddit(json);

            subReddit.Name = this.subReddit;

            // TODO: add gfycat support + get filename and right extension
            // TODO: loop through the collection and delete the elements that contain domains that are not on the support list.

            return(subReddit);
        }
示例#4
0
        public RedditSetting(SettingsPageControlleur a_settingcontrolleur, SubReddit a_Sred)
        {
            InitializeComponent();
            m_settingcontrolleur = a_settingcontrolleur;

            if (a_Sred != null)
            {
                m_BufferSred  = a_Sred;
                SredName.Text = a_Sred.SubRedditName;
                SredLink.Text = a_Sred.SubRedditLink;
            }
            else
            {
                m_BufferSred  = new SubReddit();
                SredName.Text = "Enter NAME";
                SredLink.Text = "https://www.reddit.com/r/NAME/.rss";
            }
        }
        public void RefreshDAO()
        {
            List <YoutubeChannel> t_YTchannels = new List <YoutubeChannel>();

            foreach (YoutubeEntry t_YTEntry in ProfileActu.YoutubeChannels)
            {
                try {
                    YoutubeChannel t_YTchannel = new YoutubeChannel();
                    t_YTchannel.id               = t_YTEntry.Id;
                    t_YTchannel.ChannelName      = t_YTEntry.Name;
                    t_YTchannel.ChannelLink      = t_YTEntry.Link;
                    t_YTchannel.ChannelImageLink = t_YTEntry.Image;
                    List <YoutubeVideo> t_vids = new YoutubeVideoDAO().GetChannelFeed(t_YTchannel.ChannelLink);
                    foreach (YoutubeVideo t_vid in t_vids)
                    {
                        t_vid.ChannelImage = new BitmapImage(new Uri(t_YTchannel.ChannelImageLink));
                    }
                    t_YTchannel.ChannelVideos = t_vids;
                    t_YTchannels.Add(t_YTchannel);
                } catch (Exception e) { }
            }
            YoutubeChannels = t_YTchannels;

            List <SubReddit> t_SubReddits = new List <SubReddit>();

            foreach (RedditEntry t_RedditEntry in ProfileActu.SubReddits)
            {
                try {
                    SubReddit t_subReddit = new SubReddit();
                    t_subReddit.id             = t_RedditEntry.Id;
                    t_subReddit.SubRedditName  = t_RedditEntry.Name;
                    t_subReddit.SubRedditLink  = t_RedditEntry.Link;
                    t_subReddit.SubRedditPosts = new RedditPostDAO().GetRedditPosts(t_subReddit.SubRedditLink);
                    t_SubReddits.Add(t_subReddit);
                } catch (Exception e) { }
            }
            SubReddits = t_SubReddits;

            //Refresh youtube

            /*XmlNodeList t_YTchannelsNodes = CurrentProfile.SelectNodes("./YoutubeSetting/Channel");
             * List<YoutubeChannel> t_YTchannels = new List<YoutubeChannel>();
             *
             * foreach (XmlNode t_channelNode in t_YTchannelsNodes) {
             *  try {
             *      YoutubeChannel t_YTchannel = new YoutubeChannel();
             *      t_YTchannel.ChannelName = (t_channelNode.SelectSingleNode("./Name")).InnerText;
             *      t_YTchannel.ChannelLink = (t_channelNode.SelectSingleNode("./Link")).InnerText;
             *      List<YoutubeVideo> t_vids = new YoutubeVideoDAO().GetChannelFeed(t_YTchannel.ChannelLink);
             *      t_YTchannel.ChannelImageLink = t_channelNode.SelectSingleNode("./Image").InnerText;
             *      foreach (YoutubeVideo t_vid in t_vids) {
             *          t_vid.ChannelImage = new BitmapImage(new Uri(t_YTchannel.ChannelImageLink));
             *      }
             *      t_YTchannel.ChannelVideos = t_vids;
             *      t_YTchannels.Add(t_YTchannel);
             *  } catch (Exception e) { }
             * }
             * YoutubeChannels = t_YTchannels;*/

            /*XmlNodeList t_subredditsNodes = CurrentProfile.SelectNodes("./RedditSetting/SubReddit");
             * List<SubReddit> t_SubReddits = new List<SubReddit>();
             *
             * foreach (XmlNode t_SubRedditNode in t_subredditsNodes) {
             *  try {
             *      SubReddit t_subReddit = new SubReddit();
             *      t_subReddit.SubRedditName = (t_SubRedditNode.SelectSingleNode("./Name")).InnerText;
             *      t_subReddit.SubRedditLink = (t_SubRedditNode.SelectSingleNode("./Link")).InnerText;
             *      t_subReddit.SubRedditPosts = new RedditPostDAO().GetRedditPosts(t_subReddit.SubRedditLink);
             *      t_SubReddits.Add(t_subReddit);
             *  } catch (Exception e) { }
             * }
             * SubReddits = t_SubReddits;*/

            TwitchLives = new TwitchLiveDAO().GetLivesFromEntryList(ProfileActu.TwitchLives);

            Representations = new GaieteFilmDAO().GetRepresentations();
            CsGoUpdades     = new CsGoUpdateDAO().GetUpdates();

            m_vue.DisplayMenu(CurrentTab);
        }