private void button1_Click(object sender, EventArgs e)
        {
            Uri          ur    = new Uri("http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM");
            YouTubeQuery query = new YouTubeQuery("http://gdata.youtube.com/feeds/api/channels?q=vevo");



            YouTubeFeed  videoFeed = service.Query(query);
            YouTubeEntry en        = (YouTubeEntry)videoFeed.Entries[0];

            Video          video    = request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId));
            Feed <Comment> comments = request.GetComments(video);
            string         cm       = "";

            foreach (Comment c in comments.Entries)
            {
                cm += c.Content + "\n------------------------------------------\n";
            }

            VideoInfo info = new VideoInfo();

            info.Get("yUHNUjEs7rQ");
            //Video v = request.Retrieve<Video>(videoEntryUrl);



            //Feed<Comment> comments = request.GetComments(v);

            //string cm = "";
            //foreach (Comment c in comments.Entries)
            //{
            //  cm += c.Author + c.Content + "------------------------------------------";
            //}
        }
        //----------------------------------------------------------------------------------------------------------



        //----------------------------------------------------------------------------------------------------------
        // perform youtube search
        public ActionResult MusicYTID()
        {
            string search_string = "";

            if (Request.QueryString["ss"] != null)
            {
                //---------------------------------------------------------------------
                search_string         = Request.QueryString["ss"].ToString();
                ViewBag.search_string = search_string.Replace(" ", "+");
                //---------------------------------------------------------------------
            }


            // 2.get video dynamic details
            //-----------------------------------------------------------------------------------------------------
            Video video = null;

            try
            {
                YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA");
                YouTubeRequest         request  = new YouTubeRequest(settings);
                string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + HttpUtility.UrlEncode(search_string.Replace("+", " "));
                video = request.Retrieve <Video>(new Uri(feedUrl));
            }
            catch (Exception ex) { }
            //-----------------------------------------------------------------------------------------------------


            return(View(video));
        }
        //----------------------------------------------------------------------------------------------------------
        // song landing page dynamic content
        //
        public ActionResult GetSongDynamicDetails()
        {
            // 1.parse query string
            //-----------------------------------------------------------------------------------------------------
            string song_guid = "";

            if (Request.QueryString["song_guid"] != null)
            {
                song_guid = Request.QueryString["song_guid"];
            }
            //-----------------------------------------------------------------------------------------------------


            // 2.get video dynamic details
            //-----------------------------------------------------------------------------------------------------
            Video video = new Video();

            try
            {
                YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA");
                YouTubeRequest         request  = new YouTubeRequest(settings);
                string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + song_guid;
                video = request.Retrieve <Video>(new Uri(feedUrl));
            }catch (Exception ex) {}
            //-----------------------------------------------------------------------------------------------------



            return(View(video));
        }
Example #4
0
        public VideoEntry GetById(string videoId)
        {
            var request = new YouTubeRequest(_settings);

            var video =
                request.Retrieve<Video>(new Uri(String.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId)));

            return _videoEntryFactory.Build(video);
        }
Example #5
0
        private static void LoadPlaylist(YouTubeRequest request, Playlist playlistItem)
        {
            Debug.WriteLine(String.Format("[{2}] Title: {1}\tId: {0}", playlistItem.Id, playlistItem.Title, playlistItem.CountHint));

            Playlist playlist = request.Retrieve<Playlist>(new Uri(playlistItem.Self));

            if (playlistItem.CountHint == playlist.PlaylistsEntry.Feed.Entries.Count())
                Debug.WriteLine("All Entries retrieved");
            else
                Debug.WriteLine(String.Format("{0} entry(ies) retrieved", playlist.PlaylistsEntry.Feed.Entries.Count()));

            foreach (var playlistEntryItem in playlist.PlaylistsEntry.Feed.Entries)
            {
                Video video = request.Retrieve<Video>(new Uri(playlistEntryItem.SelfUri.ToString()));
                Debug.WriteLine(String.Format("{0}\t| {1}", video.VideoId, video.Title));
                //PrintVideoEntry(video);
            }
        }
Example #6
0
        //by tag
        //feel free to change number of items, by there is a limit of 50, I believe.
        //If you want to retreive more, you have to do a loop (retrieve 1-50, then 51 to 100, etc)
        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder sb            = new StringBuilder();
            Uri           videoEntryUrl =
                new Uri("http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0");
            Video video = request.Retrieve <Video>(videoEntryUrl);

            Console.Write("Title: " + video.Title);
            Console.Write(video.Description);
        }
Example #7
0
        public static Video getVideoDetails(string videoID)
        {
            YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTube VideoDownloader", devKey);
            YouTubeRequest         request  = new YouTubeRequest(settings);
            Uri   videoEntryUrl             = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoID));
            Video video = request.Retrieve <Video>(videoEntryUrl);

            //video.Contents[0].Url;
            return(video);
        }
Example #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            Uri ur =
                new Uri(
                    "http://gdata.youtube.com/feeds/api/videos/fSgGV1llVHM&f=gdata_playlists&c=ytapi-DukaIstvan-MyYouTubeVideosF-d1ogtvf7-0&d=U1YkMvELc_arPNsH4kYosmD9LlbsOl3qUImVMV6ramM");
            YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);

            //order results by the number of views (most viewed first)
            query.OrderBy = "viewCount";

            //exclude restricted content from the search
            query.SafeSearch = YouTubeQuery.SafeSearchValues.None;
            //string ss = YouTubeQuery.TopRatedVideo;
            //http://gdata.youtube.com/feeds/api/standardfeeds/top_rated
            //search for puppies!
            query.Query = textBox1.Text;
            query.Categories.Add(new QueryCategory("Music", QueryCategoryOperator.AND));

            YouTubeFeed  videoFeed = service.Query(query);
            YouTubeEntry en        = (YouTubeEntry)videoFeed.Entries[0];
            string       s         = en.Summary.Text;
            string       s1        = en.Media.Description.Value;

            Google.GData.YouTube.MediaGroup gr = en.Media;

            Uri            videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + en.VideoId);
            Video          video         = request.Retrieve <Video>(videoEntryUrl);
            Feed <Comment> comments      = request.GetComments(video);
            string         cm            = "";

            foreach (Comment c in comments.Entries)
            {
                cm += c.Content + "\n------------------------------------------\n";
            }

            VideoInfo info = new VideoInfo();

            info.Get("yUHNUjEs7rQ");
            //Video v = request.Retrieve<Video>(videoEntryUrl);



            //Feed<Comment> comments = request.GetComments(v);

            //string cm = "";
            //foreach (Comment c in comments.Entries)
            //{
            //  cm += c.Author + c.Content + "------------------------------------------";
            //}
        }
Example #9
0
        public VideoTitleParseResult GetTitle(string id)
        {
            var settings      = new YouTubeRequestSettings("VocaDB", null);
            var request       = new YouTubeRequest(settings);
            var videoEntryUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", id));

            try {
                var video    = request.Retrieve <Video>(videoEntryUrl);
                var thumbUrl = video.Thumbnails.Count > 0 ? video.Thumbnails[0].Url : string.Empty;
                return(VideoTitleParseResult.CreateSuccess(video.Title, video.Author, thumbUrl));
            } catch (Exception x) {
                return(VideoTitleParseResult.CreateError(x.Message));
            }
        }
Example #10
0
        public VideoTitleParseResult GetTitle(string id)
        {
            var settings = new YouTubeRequestSettings("VocaDB", null);
            var request = new YouTubeRequest(settings);
            var videoEntryUrl = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", id));

            try {
                var video = request.Retrieve<Video>(videoEntryUrl);
                var thumbUrl = video.Thumbnails.Count > 0 ? video.Thumbnails[0].Url : string.Empty;
                return VideoTitleParseResult.CreateSuccess(video.Title, video.Author, thumbUrl);
            } catch (Exception x) {
                return VideoTitleParseResult.CreateError(x.Message);
            }
        }
Example #11
0
        public override VideoResponse GetVideo(VideoRequest videoRequest)
        {
            Uri videoUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoRequest.VideoId);

            try
            {
                var request = new YouTubeRequest(new YouTubeRequestSettings(Application, ApiKey));
                var video = request.Retrieve<Video>(videoUrl);
                return new VideoResponse() { Video = video };
            }
            catch (Exception e)
            {
                return new VideoResponse() { Video = null };
            }
        }
Example #12
0
 public Video RetrieveVideo(string videoId, out YouTubeRequest request)
 {
     try
     {
         request = GetRequest();
         Uri   videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoId);
         Video video         = request.Retrieve <Video>(videoEntryUrl);
         return(video);
     }
     catch (Exception ex)
     {
         request = null;
         return(null);
     }
 }
Example #13
0
        public Channel GetSquatterVideos(Collection <string> videoIds)
        {
            Channel squatterChannel = new Channel();

            squatterChannel.ID = 0;
            YouTubeRequest request = GetRequest();

            foreach (string id in videoIds)
            {
                Video vid = request.Retrieve <Video>(new Uri(string.Format(_apiVideosUrl, id)));
                squatterChannel.Feed.Add(new ChannelVideo(vid));
            }

            return(squatterChannel);
        }
Example #14
0
        static void Main(string[] args)
        {
            Uri youTubeLink = new Uri("http://www.youtube.com/watch?v=ItqQ2EZziB8");
            var parameters = System.Web.HttpUtility.ParseQueryString(youTubeLink.Query);
            var videoId = parameters["v"];

            Uri youTubeApi = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId));
            YouTubeRequestSettings settings = new YouTubeRequestSettings(null, null);

            YouTubeRequest request = new YouTubeRequest(settings);
            var result = request.Retrieve<Video>(youTubeApi);

            Console.WriteLine(result.Title);
            Console.WriteLine(result.Description);
            Console.WriteLine(result.ViewCount);

            Console.ReadLine();
        }
Example #15
0
        static void Main(string[] args)
        {
            Uri youTubeLink = new Uri("http://www.youtube.com/watch?v=ItqQ2EZziB8");
            var parameters  = System.Web.HttpUtility.ParseQueryString(youTubeLink.Query);
            var videoId     = parameters["v"];

            Uri youTubeApi = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}", videoId));
            YouTubeRequestSettings settings = new YouTubeRequestSettings(null, null);

            YouTubeRequest request = new YouTubeRequest(settings);
            var            result  = request.Retrieve <Video>(youTubeApi);

            Console.WriteLine(result.Title);
            Console.WriteLine(result.Description);
            Console.WriteLine(result.ViewCount);

            Console.ReadLine();
        }
Example #16
0
        public void YouTubeGetTest()
        {
            Tracing.TraceMsg("Entering YouTubeGetTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytDevKey, this.ytUser, this.ytPwd);

            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed <Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            foreach (Video v in feed.Entries)
            {
                // remove the etag to force a refresh
                v.YouTubeEntry.Etag = null;
                Video refresh = f.Retrieve(v);

                Assert.AreEqual(refresh.VideoId, v.VideoId, "The ID values should be equal");
            }
        }
Example #17
0
        public static Google.YouTube.Video GetYouTubeVideo(string id = "")
        {
            try {
                // Initiate video object
                Google.YouTube.Video video = new Google.YouTube.Video();

                // Initiate YouTube request object
                YouTubeRequestSettings settings = new YouTubeRequestSettings("curtmfg", "AI39si6iCFZ_NutrvZe04i9_m7gFhgmPK1e7LF6-yHMAwB-GDO3vC3eD0R-5lberMQLdglNjH3IWUMe3tJXe9qrFe44n2jAUyg");
                YouTubeRequest req = new YouTubeRequest(settings);
                req.Proxy = null;

                // Create the URI and make request to YouTube
                Uri video_url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + id);
                video = req.Retrieve<Google.YouTube.Video>(video_url);

                return video;
            } catch (Exception) {
                return new Google.YouTube.Video();
            }
        }
Example #18
0
        private void postComment(object sender, RoutedEventArgs e)
        {
            YouTubeRequest req = new YouTubeRequest(new YouTubeRequestSettings(MainWindow.APP_NAME, MainWindow.DEV_KEY, MainWindow.mProgramProperties.Username, MainWindow.mProgramProperties.Password));

            Uri videoEntryUrl = new Uri(string.Format("{0}/{1}", Google.GData.YouTube.YouTubeQuery.DefaultVideoUri, videoId));
            Google.YouTube.Video newVideo = req.Retrieve<Google.YouTube.Video>(videoEntryUrl);

            Comment c = new Comment();
            c.Content = commentTxtBox.Text.ToString();
            try
            {
                req.AddComment(newVideo, c);
            }
            catch (Google.GData.Client.GDataRequestException ex)
            {
                MessageBox.Show("You have post too many comments! Try again later!");
                return;
            }

            this.commentTxtBox.Text = "";
        }
Example #19
0
 /// <summary>
 /// Creates a track using a YouTube video ID
 /// </summary>
 /// <param name="path">The path of the track</param>
 /// <returns>A TrackData structure representing the YouTube track</returns>
 public static TrackData CreateTrack(string path)
 {
     try
     {
         string         id      = GetYouTubeID(path);
         YouTubeRequest request = new YouTubeRequest(settings);
         Uri            url     = new Uri(uriBase + "/feeds/api/videos/" + id);
         Video          v       = request.Retrieve <Video>(url);
         if (v == null)
         {
             U.L(LogLevel.Warning, "YOUTUBE", "Could not find video with ID '" + id + "'");
             return(null);
         }
         return(CreateTrack(v));
     }
     catch (Exception e)
     {
         return(null);
         //return new TrackData { Title = "Error", Artist = "Error" };
     }
 }
Example #20
0
        private void getstuff(string videoid)
        {
            int tempvidswatched = RipLeech.Properties.Settings.Default.videoswatched;

            RipLeech.Properties.Settings.Default.videoswatched = tempvidswatched + 1;
            RipLeech.Properties.Settings.Default.Save();
            webBrowser1.Navigate("http://youtube.com/v/" + videoid + "&vq=hd720");
            YouTubeRequest request = new YouTubeRequest(settings);

            try
            {
                Uri          videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoid);
                Video        video         = request.Retrieve <Video>(videoEntryUrl);
                Feed <Video> relatedVideos = request.GetRelatedVideos(video);
                printVideoFeed(relatedVideos);
                printVideoEntry(video);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #21
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {

                //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

                //while (enumerator.MoveNext())
                //{

                //    HttpContext.Current.Cache.Remove(enumerator.Key.ToString());

                //}

                Artists allartsis = new Artists();
                allartsis.RemoveCache();

                if (gvwRequestedVideos.SelectedDataKey != null)
                {
                    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value));
                    vidreq.StatusType = 'A';
                    vidreq.Update();
                }

                vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", txtVideoKey.Text);

                vid.Duration = (float)Convert.ToDouble(txtDuration.Text);
                vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text);
                vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text);
                vid.ProviderCode = ddlVideoProvider.SelectedValue;
                vid.ProviderUserKey = txtUserName.Text;
                vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue);
                vid.IsEnabled = chkEnabled.Checked;
                // vid.IsHidden = chkHidden.Checked;
                vid.EnableTrim = chkEnabled.Checked;

                /// publish date
                YouTubeRequestSettings yousettings =
                    new YouTubeRequestSettings("You Manager", devkey, username, password);
                YouTubeRequest yourequest;
                Uri Url;
                Google.YouTube.Video video;

                yourequest = new YouTubeRequest(yousettings);
                Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                video = new Google.YouTube.Video();
                video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                vid.PublishDate = video.YouTubeEntry.Published;

                if (vid.VideoID == 0)
                {
                    vid.Create();
                }
                else
                    vid.Update();

                // if there is a contest, add it now since there is an id
                if (ddlContest.SelectedValue != unknownValue)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    ContestVideo cv = new ContestVideo();

                    cv.ContestID = Convert.ToInt32(ddlContest.SelectedValue);
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                // vid type
                if (!string.IsNullOrWhiteSpace(this.ddlVideoType.SelectedValue)
                    && this.ddlVideoType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                        ddlVideoType.SelectedValue), vid.VideoID);
                }

                // human
                if (!string.IsNullOrWhiteSpace(this.ddlHumanType.SelectedValue)
                    && this.ddlHumanType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                        ddlHumanType.SelectedValue), vid.VideoID);
                }

                // footage
                if (!string.IsNullOrWhiteSpace(this.ddlFootageType.SelectedValue)
                    && this.ddlFootageType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                        ddlFootageType.SelectedValue), vid.VideoID);
                }

                //// guitar
                //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue)
                //    && this.ddlGuitarType.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID);
                //}

                //// Language
                //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue)
                //    && this.ddlLanguage.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID);
                //}

                //// genre
                //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue)
                //    && this.ddlGenre.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID);
                //}

                //// difficulty
                //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue)
                //    && this.ddlDifficultyLevel.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID);
                //}

                VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                if (string.IsNullOrEmpty(txtArtist1.Text.Trim()))
                {
                    artst = new Artist(ddlArtist1.SelectedValue);
                }
                else
                {
                    artst = new Artist(txtArtist1.Text);
                }

                if (artst.ArtistID == 0)
                {
                    artst.AltName = FromString.URLKey(artst.Name);
                    artst.Create();
                }

                if (string.IsNullOrEmpty(txtArtistSong1.Text))
                {
                    sng = new Song(artst.ArtistID, ddlArtistSongs1.SelectedValue);
                }
                else
                {
                    sng = new Song(artst.ArtistID, txtArtistSong1.Text);
                }

                if (sng.SongID == 0)
                {
                    sng.SongKey = FromString.URLKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                // song 2

                if ((ddlArtist2.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist2.SelectedValue)) ||
                    !string.IsNullOrEmpty(txtArtist2.Text))
                {
                    artst = null;
                    sng = null;

                    if (string.IsNullOrEmpty(txtArtist2.Text.Trim()))
                    {
                        artst = new Artist(ddlArtist2.SelectedValue);
                    }
                    else
                    {
                        artst = new Artist(txtArtist2.Text);
                    }

                    if (artst.ArtistID == 0)
                    {
                        artst.AltName = FromString.URLKey(artst.Name);
                        artst.Create();
                    }

                    if (string.IsNullOrEmpty(txtArtistSong2.Text))
                    {
                        sng = new Song(artst.ArtistID, ddlArtistSongs2.SelectedValue);
                    }
                    else
                    {
                        sng = new Song(artst.ArtistID, txtArtistSong2.Text);
                    }

                    if (sng.SongID == 0)
                    {
                        sng.SongKey = FromString.URLKey(sng.Name);
                        sng.Create();
                    }

                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 2);

                    if ((ddlArtist3.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist3.SelectedValue)) ||
                        !string.IsNullOrEmpty(txtArtist3.Text))
                    {

                        // song 3

                        artst = null;
                        sng = null;

                        if (string.IsNullOrEmpty(txtArtist3.Text))
                        {
                            artst = new Artist(ddlArtist3.SelectedValue);
                        }
                        else
                        {
                            artst = new Artist(txtArtist3.Text);
                        }

                        if (artst.ArtistID == 0)
                        {
                            artst.AltName = FromString.URLKey(artst.Name);
                            artst.Create();
                        }

                        if (string.IsNullOrEmpty(txtArtistSong3.Text))
                        {
                            sng = new Song(artst.ArtistID, ddlArtistSongs3.SelectedValue);
                        }
                        else
                        {
                            sng = new Song(artst.ArtistID, txtArtistSong3.Text);
                        }

                        if (sng.SongID == 0)
                        {
                            sng.SongKey = FromString.URLKey(sng.Name);
                            sng.Create();
                        }

                        VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 3);

                        if ((ddlArtist4.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist4.SelectedValue)) ||
                            !string.IsNullOrEmpty(txtArtist4.Text))
                        {

                            // song 4

                            artst = null;
                            sng = null;

                            if (string.IsNullOrEmpty(txtArtist4.Text))
                            {
                                artst = new Artist(ddlArtist4.SelectedValue);
                            }
                            else
                            {
                                artst = new Artist(txtArtist4.Text);
                            }

                            if (artst.ArtistID == 0)
                            {
                                artst.AltName = FromString.URLKey(artst.Name);
                                artst.Create();
                            }

                            if (string.IsNullOrEmpty(txtArtistSong4.Text))
                            {
                                sng = new Song(artst.ArtistID, ddlArtistSongs4.SelectedValue);
                            }
                            else
                            {
                                sng = new Song(artst.ArtistID, txtArtistSong4.Text);
                            }

                            if (sng.SongID == 0)
                            {
                                sng.SongKey = FromString.URLKey(sng.Name);
                                sng.Create();
                            }

                            VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 4);

                            if ((ddlArtist5.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist5.SelectedValue)) ||
                                !string.IsNullOrEmpty(txtArtist5.Text))
                            {

                                // song 5

                                artst = null;
                                sng = null;

                                if (string.IsNullOrEmpty(txtArtist5.Text))
                                {
                                    artst = new Artist(ddlArtist5.SelectedValue);
                                }
                                else
                                {
                                    artst = new Artist(txtArtist5.Text);
                                }

                                if (artst.ArtistID == 0)
                                {
                                    artst.AltName = FromString.URLKey(artst.Name);
                                    artst.Create();
                                }

                                if (string.IsNullOrEmpty(txtArtistSong5.Text))
                                {
                                    sng = new Song(artst.ArtistID, ddlArtistSongs5.SelectedValue);
                                }
                                else
                                {
                                    sng = new Song(artst.ArtistID, txtArtistSong5.Text);
                                }

                                if (sng.SongID == 0)
                                {
                                    sng.SongKey = FromString.URLKey(sng.Name);
                                    sng.Create();
                                }

                                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 5);

                                if ((ddlArtist6.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist6.SelectedValue)) ||
                            !string.IsNullOrEmpty(txtArtist6.Text))
                                {

                                    // song 6

                                    artst = null;
                                    sng = null;

                                    if (string.IsNullOrEmpty(txtArtist6.Text))
                                    {
                                        artst = new Artist(ddlArtist6.SelectedValue);
                                    }
                                    else
                                    {
                                        artst = new Artist(txtArtist6.Text);
                                    }

                                    if (artst.ArtistID == 0)
                                    {
                                        artst.AltName = FromString.URLKey(artst.Name);
                                        artst.Create();
                                    }

                                    if (string.IsNullOrEmpty(txtArtistSong6.Text))
                                    {
                                        sng = new Song(artst.ArtistID, ddlArtistSongs6.SelectedValue);
                                    }
                                    else
                                    {
                                        sng = new Song(artst.ArtistID, txtArtistSong6.Text);
                                    }

                                    if (sng.SongID == 0)
                                    {
                                        sng.SongKey = FromString.URLKey(sng.Name);
                                        sng.Create();
                                    }

                                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 6);
                                }

                            }

                        }

                    }
                }

                //  RefreshLists();

                lblStatus.Text = "OK";
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }

            LoadGrid();
        }
Example #22
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Should delete work on local files, or let the user do that manually?
            if (MessageBox.Show("WARNING: Deleting this file will delete it locally!", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes && listVideosView.FocusedItem.SubItems.Count > 1)
            {
                YouTubeRequestSettings settings = new YouTubeRequestSettings("Deprecated", key, Youtube_Uploader.Properties.Settings.Default.UsernameYT, Youtube_Uploader.Properties.Settings.Default.PasswordYT);
                YouTubeRequest request = new YouTubeRequest(settings);
                Uri videoEntryUrl = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", TrimEmail(Youtube_Uploader.Properties.Settings.Default.UsernameYT), listVideosView.FocusedItem.SubItems[2].Text));
                Video video = request.Retrieve<Video>(videoEntryUrl);
                request.Delete(video);

                VideoFilename.RemoveAt(VideoId.IndexOf(video.VideoId));
                VideoStatus.RemoveAt(VideoId.IndexOf(video.VideoId));
                VideoId.RemoveAt(VideoId.IndexOf(video.VideoId));

                File.Delete(includeTextBox.Text + "\\" + textBox_UploadFile.Text);

                drawVideoList();
            }
        }
Example #23
0
        public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath)
        {
            //DownloadInfo info = null;
            YouTubeRequestSettings settings = new YouTubeRequestSettings(Settings.Default.youtubeAppName, Settings.Default.youtubeDevKey);
            YouTubeRequest request = new YouTubeRequest(settings);
            Uri videoEntryUrl = new Uri(urlPageVideo);
            Video video = request.Retrieve<Video>(videoEntryUrl);

            String videoInfo = printVideoEntry(video);

            String urlVideoFile = video.Contents[0].Url;
            //DownloadPageToFile(urlVideoFile, @"D:\Video\Youtube\Test\test");
            WebClient webClient = new WebClient();
            byte[] buffer = webClient.DownloadData(urlVideoFile);
            byte[] fileType = new byte[3];
            byte[] header = new byte[5];
            byte[] compressedData = new byte[buffer.Length - 8];
            for (int index = 0; index < 3; index++)
                fileType[index] = buffer[index];
            for (int index = 3; index < 8; index++)
                header[index-3] = buffer[index];
            for (int index = 8; index < buffer.Length; index++)
                compressedData[index-8] = buffer[index];
            MemoryStream ms = new MemoryStream(compressedData);
            DeflateStream zipStream = new DeflateStream(ms, CompressionMode.Decompress);
            byte[] tempBufer = new byte[256];
            FileStream fichier = new FileStream(savePath + "test.swf",
                                                FileMode.Create, FileAccess.Write, FileShare.None,
                                                tempBufer.Length, false);
            fichier.Write(fileType, 0, fileType.Length);
            fichier.Write(header, 0, header.Length);
            fichier.Flush();
            int offset = 0;
            int totalCount = 0;
            int bytesRead;
            while ((bytesRead = zipStream.Read(tempBufer, 0, tempBufer.Length)) != 0)
            {
                fichier.Write(tempBufer, 0, tempBufer.Length);
                offset += bytesRead;
                totalCount += bytesRead;
            }
            zipStream.Close();
            ms.Close();
            fichier.Close();
            /*long videoFileSize = 0;
            String titreVideo = null;
            if (urlVideoFile != null)
            {
                videoFileSize = getVideoFileSizeAndType(urlVideoFile);
                if (videoFileSize > 0)
                {
                    titreVideo = video.Title;
                    if (titreVideo != null)
                    {
                        info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this);
                        if (saveDialog)
                        {
                            info = LaunchSaveDlg(info);
                        }
                    }
                }
            }*/

            return null;
        }
Example #24
0
 private bool ConfirmID(string vidID)
 {
     YouTubeRequestSettings settings = new YouTubeRequestSettings("Deprecated", key, Youtube_Uploader.Properties.Settings.Default.UsernameYT, Youtube_Uploader.Properties.Settings.Default.PasswordYT);
     YouTubeRequest request = new YouTubeRequest(settings);
     //Uri videoEntryUrl = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", "user00015", vidID));
     string VideoEntryUrl = @"http://gdata.youtube.com/feeds/api/videos/";
     Uri videoEntryUrl = new Uri(VideoEntryUrl + vidID);
     try
     {
         newVideo = request.Retrieve<Video>(videoEntryUrl); //Make this Async eventually if possible.
         return true;
     }
     catch { return false; }
 }
Example #25
0
 private void getstuff(string videoid)
 {
     int tempvidswatched = RipLeech.Properties.Settings.Default.videoswatched;
     RipLeech.Properties.Settings.Default.videoswatched = tempvidswatched + 1;
     RipLeech.Properties.Settings.Default.Save();
     webBrowser1.Navigate("http://youtube.com/v/" + videoid + "&vq=hd720");
     YouTubeRequest request = new YouTubeRequest(settings);
     try
     {
         Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoid);
         Video video = request.Retrieve<Video>(videoEntryUrl);
         Feed<Video> relatedVideos = request.GetRelatedVideos(video);
         printVideoFeed(relatedVideos);
         printVideoEntry(video);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #26
0
        public ActionResult VideoSubmit(string video, string videoType, string personType,
            string footageType, string band, string song, string contestID)
        {
            if (string.IsNullOrWhiteSpace(video))
            {
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
            }
            VideoRequest vir = new VideoRequest();

            vir.RequestURL = video;

            string vidKey = string.Empty;

            vir.RequestURL = vir.RequestURL.Replace("https", "http");

            if (vir.RequestURL.Contains("http://youtu.be/"))
            {
                vir.VideoKey = vir.RequestURL.Replace("http://youtu.be/", string.Empty);
            }
            else if (vir.RequestURL.Contains("http://www.youtube.com/watch?"))
            {
                NameValueCollection nvcKey = System.Web.HttpUtility.ParseQueryString(vir.RequestURL.Replace("http://www.youtube.com/watch?", string.Empty));

                vir.VideoKey = nvcKey["v"];
                vidKey = nvcKey["v"];
            }
            else
            {
                // invalid
                vir.StatusType = 'I';
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
            }

            if (string.IsNullOrWhiteSpace(videoType) ||
                string.IsNullOrWhiteSpace(personType) ||
                string.IsNullOrWhiteSpace(footageType) ||
                string.IsNullOrWhiteSpace(band) ||
                string.IsNullOrWhiteSpace(song))
            {
                // invalid
                vir.StatusType = 'P';
                Response.Redirect("~/videosubmission.aspx?statustype=P");
                return new EmptyResult();
            }

            try
            {

                //IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator();

                //while (enumerator.MoveNext())
                //{

                //    HttpContext.Current.Cache.Remove(enumerator.Key.ToString());

                //}

                //Artists allartsis = new Artists();
                //allartsis.RemoveCache();

                //if (gvwRequestedVideos.SelectedDataKey != null)
                //{
                //    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value));
                //    vidreq.StatusType = 'A';
                //    vidreq.Update();
                //}

                BootBaronLib.AppSpec.DasKlub.BOL.Video vid = new BootBaronLib.AppSpec.DasKlub.BOL.Video("YT", vidKey);

                vid.ProviderCode = "YT";

                Google.YouTube.Video video2;
                video2 = new Google.YouTube.Video();

                try
                {
                    YouTubeRequestSettings yousettings = new YouTubeRequestSettings("You Manager", devkey, username, password);
                    YouTubeRequest yourequest;
                    Uri Url;

                    yourequest = new YouTubeRequest(yousettings);
                    Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vidKey);

                    video2 = yourequest.Retrieve<Google.YouTube.Video>(Url);
                    vid.Duration = (float)Convert.ToDouble(video2.YouTubeEntry.Duration.Seconds);
                    vid.ProviderUserKey = video2.Uploader;
                    vid.PublishDate = video2.YouTubeEntry.Published;
                }
                catch (GDataRequestException)
                {
                    vid.IsEnabled = false;
                    vid.Update();
                    //litVideo.Text = string.Empty;
                    // return;

                    // invalid
                    vir.StatusType = 'I';
                    Response.Redirect("~/videosubmission.aspx?statustype=I");
                    return new EmptyResult();
                }

                vid.VolumeLevel = 5;
                // vid.HumanType = personType;

                //    t(string video, string videoType, string personType,
                //string footageType, string band, string song, string contestID)

                //  vid.VideoType = videoType;

                //vid.Duration = (float)Convert.ToDouble(txtDuration.Text);
                //vid.Intro = (float)Convert.ToDouble(txtSecondsIn.Text);
                //vid.LengthFromStart = (float)Convert.ToDouble(txtElasedEnd.Text);
                //vid.ProviderCode = ddlVideoProvider.SelectedValue;
                //vid.ProviderUserKey = txtUserName.Text;
                //vid.VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue);
                //vid.IsEnabled = chkEnabled.Checked;
                //// vid.IsHidden = chkHidden.Checked;
                //vid.EnableTrim = chkEnabled.Checked;

                ///// publish date
                //YouTubeRequestSettings yousettings =
                //    new YouTubeRequestSettings("You Manager", devkey, username, password);
                //YouTubeRequest yourequest;
                //Uri Url;

                //yourequest = new YouTubeRequest(yousettings);
                //Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                //video = new Google.YouTube.Video();
                //video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                //vid.PublishDate = video.YouTubeEntry.Published;

                if (string.IsNullOrWhiteSpace(vid.ProviderKey))
                {
                    // invalid
                    vir.StatusType = 'I';
                    Response.Redirect("~/videosubmission.aspx?statustype=I");
                    return new EmptyResult();
                }

                if (vid.VideoID == 0)
                {
                    vid.IsHidden = false;
                    vid.IsEnabled = true;
                    vid.Create();
                }
                else
                {
                    vid.Update();
                }

                // if there is a contest, add it now since there is an id
                int subContestID = 0;
                if (!string.IsNullOrWhiteSpace(contestID) && int.TryParse(contestID, out subContestID) && subContestID > 0)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    ContestVideo cv = new ContestVideo();

                    cv.ContestID = subContestID;
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                PropertyType propTyp = null;
                MultiProperty mp = null;

                // vid type

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(videoType), vid.VideoID);

                // human

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(personType), vid.VideoID);

                // footage

                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                mp.RemoveCache();
                MultiPropertyVideo.AddMultiPropertyVideo(Convert.ToInt32(footageType), vid.VideoID);

                //// guitar
                //if (!string.IsNullOrWhiteSpace(this.ddlGuitarType.SelectedValue)
                //    && this.ddlGuitarType.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GUITR);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGuitarType.SelectedValue), vid.VideoID);
                //}

                //// Language
                //if (!string.IsNullOrWhiteSpace(this.ddlLanguage.SelectedValue)
                //    && this.ddlLanguage.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.LANGE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlLanguage.SelectedValue), vid.VideoID);
                //}

                //// genre
                //if (!string.IsNullOrWhiteSpace(this.ddlGenre.SelectedValue)
                //    && this.ddlGenre.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.GENRE);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(ddlGenre.SelectedValue), vid.VideoID);
                //}

                //// difficulty
                //if (!string.IsNullOrWhiteSpace(this.ddlDifficultyLevel.SelectedValue)
                //    && this.ddlDifficultyLevel.SelectedValue != selectText)
                //{
                //    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.DIFFC);
                //    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                //    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                //    mp.RemoveCache();
                //    MultiPropertyVideo.AddMultiPropertyVideo(
                //        Convert.ToInt32(this.ddlDifficultyLevel.SelectedValue), vid.VideoID);
                //}

                //VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                Artist artst = new Artist(band.Trim());

                if (artst.ArtistID == 0)
                {
                    artst.GetArtistByAltname(band.Trim());
                }

                if (artst.ArtistID == 0)
                {
                    artst.Name = band.Trim();
                    artst.AltName = FromString.URLKey(artst.Name);
                    artst.Create();
                }

                Song sng = new Song(artst.ArtistID, song.Trim());

                if (sng.SongID == 0)
                {
                    sng.Name = sng.Name.Trim();
                    sng.SongKey = FromString.URLKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                //  RefreshLists();

                //                lblStatus.Text = "OK";

                if (vid.VideoID > 0)
                {
                    Response.Redirect(vid.VideoURL);// just send them to it
                }
            }
            catch
            {
                //              lblStatus.Text = ex.Message;

                //{
                Response.Redirect("~/videosubmission.aspx?statustype=I");
                return new EmptyResult();
                //}

            }

            //Video v1 = new Video();

            //if (!string.IsNullOrEmpty(vir.VideoKey))
            //{
            //    v1 = new Video("YT", vir.VideoKey);
            //}

            //if (v1.VideoID > 0 && v1.IsEnabled)
            //{
            //     Response.Redirect(v1.VideoURL);// just send them to it
            //     return new EmptyResult();
            //}

            //vir.GetVideoRequest();

            //if (vir.StatusType == 'W')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=W");
            //    return new EmptyResult();
            //}
            //else if (vir.StatusType == 'R')
            //{
            //     Response.Redirect("~/videosubmission.aspx?statustype=R");
            //     return new EmptyResult();
            //}

            //vir.StatusType = 'W';
            //vir.Create();
            // Response.Redirect("~/videosubmission.aspx?statustype=W");
            // return new EmptyResult();

            //if (vir.StatusType == 'W')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=W");
            //    return new EmptyResult();
            //}
            //else if (vir.StatusType == 'R')
            //{
            //    Response.Redirect("~/videosubmission.aspx?statustype=R");
            //    return new EmptyResult();
            //}
            //else
            //{
            //    v1 = new Video("YT", vir.VideoKey);

            //    if (v1.VideoID > 0 && v1.IsEnabled)
            //    {
            //        Response.Redirect(v1.VideoURL);// just send them to it
            //    }
            //    else
            //    {
            //        vir.StatusType = 'W';
            //        vir.Create();
            //        Response.Redirect("~/videosubmission.aspx?statustype=W");
            //        return new EmptyResult();
            //    }
            //}

            return new EmptyResult();
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test on the YouTube factory object</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void YouTubeGetTest()
        {
            Tracing.TraceMsg("Entering YouTubeGetTest");

            YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd);
            settings.PageSize = 15;
            YouTubeRequest f = new YouTubeRequest(settings);

            Feed<Video> feed = f.GetStandardFeed(YouTubeQuery.MostPopular);

            foreach (Video v in feed.Entries)
            {
                // remove the etag to force a refresh
                v.YouTubeEntry.Etag = null;
                Video refresh = f.Retrieve(v);

                Assert.AreEqual(refresh.VideoId, v.VideoId, "The ID values should be equal");
            }
        }
Example #28
0
        private void updateCommentBw_DoWork(object sender, DoWorkEventArgs e)
        {
            YouTubeRequest req = new YouTubeRequest(new YouTubeRequestSettings("YoutubeUploader", MainWindow.DEV_KEY));
            Uri videoEntryUrl = new Uri(string.Format("{0}/{1}", Google.GData.YouTube.YouTubeQuery.DefaultVideoUri, videoId));
            Google.YouTube.Video newVideo = req.Retrieve<Google.YouTube.Video>(videoEntryUrl);

            Feed<Comment> comments = req.GetComments(newVideo);
            List<object> arg = new List<object>();
            arg.Add(comments);
            e.Result = arg;
        }
        public ActionResult SubmitAddNewSongPopup(string Song_Title, string Song_Guid, int?Sel_Playlist_ID, int?StayHereCheck)
        {
            // 1.genral declarations
            //--------------------------------------------------------------------------------------------
            hypster_tv_DAL.Hypster_Entities   hypDB              = new hypster_tv_DAL.Hypster_Entities();
            hypster_tv_DAL.songsManagement    songsManager       = new hypster_tv_DAL.songsManagement();
            hypster_tv_DAL.memberManagement   userManager        = new hypster_tv_DAL.memberManagement();
            hypster_tv_DAL.playlistManagement playlistManagement = new hypster_tv_DAL.playlistManagement();
            //--------------------------------------------------------------------------------------------



            //get curr user
            //-----------------------------------------------------------------------------------------
            hypster_tv_DAL.Member curr_user = new hypster_tv_DAL.Member();
            curr_user = userManager.getMemberByUserName(User.Identity.Name);
            //-----------------------------------------------------------------------------------------



            //check if user has default playlist
            //-----------------------------------------------------------------------------------------
            if (curr_user.active_playlist == 0)
            {
                hypster_tv_DAL.Playlist create_playlist = new hypster_tv_DAL.Playlist();
                create_playlist.name   = curr_user.username + "'s playlist";
                create_playlist.userid = curr_user.id;


                if (create_playlist.name.Length > 60)
                {
                    create_playlist.name = create_playlist.name.Substring(0, 60);
                }


                hypDB.Playlists.AddObject(create_playlist);
                hypDB.SaveChanges();

                List <hypster_tv_DAL.Playlist> playlists_list = playlistManagement.GetUserPlaylists(curr_user.id);
                if (playlists_list.Count > 0)
                {
                    curr_user.active_playlist = playlists_list[0].id;
                    userManager.SetUserDefaultPlaylist(User.Identity.Name, curr_user.id, curr_user.active_playlist);
                }
                //else error - need to have dafult playlist
            }
            //-----------------------------------------------------------------------------------------



            //check if user selected playlist
            //-----------------------------------------------------------------------------------------
            if (Sel_Playlist_ID == null || Sel_Playlist_ID == 0)
            {
                Sel_Playlist_ID = curr_user.active_playlist;
            }
            //-----------------------------------------------------------------------------------------



            // get last sort_number
            //-----------------------------------------------------------------------------------------
            short Sel_Sort_Order = 0;

            //List<hypster_tv_DAL.PlaylistData_Song> songs_list = new List<hypster_tv_DAL.PlaylistData_Song>();
            //songs_list = playlistManagement.GetSongsForPlayList(curr_user.id, (int)Sel_Playlist_ID);
            //if (songs_list.Count > 0)
            //{
            //    Sel_Sort_Order = songs_list[0].sortid;
            //    for (int i = 0; i < songs_list.Count; i++)
            //    {
            //        if (songs_list[i].sortid > Sel_Sort_Order)
            //            Sel_Sort_Order = songs_list[i].sortid;
            //    }
            //}
            //Sel_Sort_Order += 1;


            playlistManagement.IncrementPlaylistSongOrder(curr_user.id, (int)Sel_Playlist_ID);
            //set sort order to first position
            Sel_Sort_Order = 1;
            //-----------------------------------------------------------------------------------------



            //get song by guid
            //-----------------------------------------------------------------------------------------
            hypster_tv_DAL.Song song = new hypster_tv_DAL.Song();
            song = songsManager.GetSongByGUID(Song_Guid);
            //-----------------------------------------------------------------------------------------



            if (Song_Title.Length > 160)
            {
                Song_Title = Song_Title.Substring(0, 160);
            }



            //-----------------------------------------------------------------------------------------
            if (song.id == 0) //add new song
            {
                string video_Author        = "";
                float  video_RatingAverage = 0;
                byte   video_AppControl    = 0;
                string video_Title         = "";

                try
                {
                    //need to get song details
                    YouTubeRequestSettings settings = new YouTubeRequestSettings("hypster", "AI39si5TNjKgF6yiHwUhKbKwIui2JRphXG4hPXUBdlrNh4XMZLXu--lf66gVSPvks9PlWonEk2Qv9fwiadpNbiuh-9TifCNsqA");
                    YouTubeRequest         request  = new YouTubeRequest(settings);
                    string feedUrl = "http://gdata.youtube.com/feeds/api/videos/" + Song_Guid;
                    Video  video   = request.Retrieve <Video>(new Uri(feedUrl));


                    if (video.Author != null)
                    {
                        video_Author = video.Uploader;
                    }
                    if (video.RatingAverage != null)
                    {
                        video_RatingAverage = (float)video.RatingAverage;
                    }
                    if (video.AppControl != null)
                    {
                        video_AppControl = 1;
                    }
                    if (video.Title != null)
                    {
                        video_Title = video.Title;
                    }
                }
                catch (Exception ex)
                {
                }


                //need to modify to add more song params
                hypster_tv_DAL.Song new_song = new hypster_tv_DAL.Song();
                new_song.Title            = video_Title;
                new_song.YoutubeId        = Song_Guid;
                new_song.adddate          = DateTime.Now;
                new_song.YoutubeProcessed = false;


                new_song.Author      = video_Author;
                new_song.Rating      = video_RatingAverage;
                new_song.Syndication = video_AppControl;

                hypDB.Songs.AddObject(new_song);
                hypDB.SaveChanges();



                //get newely added song
                song = songsManager.GetSongByGUID(Song_Guid);


                //add to playlist data
                hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData();
                new_playlistData.playlist_id = Sel_Playlist_ID;
                new_playlistData.songid      = song.id;
                new_playlistData.sortid      = Sel_Sort_Order;
                new_playlistData.userid      = userManager.getMemberByUserName(User.Identity.Name).id;

                hypDB.PlaylistDatas.AddObject(new_playlistData);
                hypDB.SaveChanges();
            }
            else //if song exist in database
            {
                //add to playlist data
                hypster_tv_DAL.PlaylistData new_playlistData = new hypster_tv_DAL.PlaylistData();
                new_playlistData.playlist_id = Sel_Playlist_ID;
                new_playlistData.songid      = song.id;
                new_playlistData.sortid      = Sel_Sort_Order;
                new_playlistData.userid      = curr_user.id;


                hypDB.PlaylistDatas.AddObject(new_playlistData);
                hypDB.SaveChanges();
            }
            //-----------------------------------------------------------------------------------------



            //-----------------------------------------------------------------------------------------
            return(Content("SUCCESS", "text/html"));
            //-----------------------------------------------------------------------------------------
        }
 public Video RetrieveVideo(string videoId, out YouTubeRequest request)
 {
     try
     {
         request = GetRequest();
         Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoId);
         Video video = request.Retrieve<Video>(videoEntryUrl);
         return video;
     }         
     catch (Exception ex)
     {
         request = null;
         return null;
     }
 }
Example #31
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var allartsis = new Artists();
                allartsis.RemoveCache();

                if (gvwRequestedVideos.SelectedDataKey != null)
                {
                    vidreq = new VideoRequest(Convert.ToInt32(gvwRequestedVideos.SelectedDataKey.Value))
                    {
                        StatusType = 'A'
                    };
                    vidreq.Update();
                }

                vid = new Video("YT", txtVideoKey.Text)
                {
                    Duration = (float) Convert.ToDouble(txtDuration.Text),
                    Intro = (float) Convert.ToDouble(txtSecondsIn.Text),
                    LengthFromStart = (float) Convert.ToDouble(txtElasedEnd.Text),
                    ProviderCode = ddlVideoProvider.SelectedValue,
                    ProviderUserKey = txtUserName.Text,
                    VolumeLevel = Convert.ToInt32(ddlVolumeLevel.SelectedValue),
                    IsEnabled = chkEnabled.Checked,
                    EnableTrim = chkEnabled.Checked
                };

                // vid.IsHidden = chkHidden.Checked;

                /// publish date
                var yousettings = new YouTubeRequestSettings("Das Klub", devkey);
                var yourequest = new YouTubeRequest(yousettings);
                var Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + vid.ProviderKey);
                var video = new Google.YouTube.Video();
                video = yourequest.Retrieve<Google.YouTube.Video>(Url);
                vid.PublishDate = video.YouTubeEntry.Published;

                if (vid.VideoID == 0)
                {
                    vid.Create();
                }
                else
                    vid.Update();

                // if there is a contest, add it now since there is an id
                if (ddlContest.SelectedValue != unknownValue)
                {
                    //TODO: check if it already is in the contest

                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);

                    var cv = new ContestVideo();

                    cv.ContestID = Convert.ToInt32(ddlContest.SelectedValue);
                    cv.VideoID = vid.VideoID;
                    cv.Create();
                }
                else
                {
                    // TODO: JUST REMOVE FROM CURRENT CONTEST, NOT ALL
                    ContestVideo.DeleteVideoFromAllContests(vid.VideoID);
                }

                // vid type
                if (!string.IsNullOrWhiteSpace(ddlVideoType.SelectedValue)
                    && ddlVideoType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                            ddlVideoType.SelectedValue), vid.VideoID);
                }

                // human
                if (!string.IsNullOrWhiteSpace(ddlHumanType.SelectedValue)
                    && ddlHumanType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                            ddlHumanType.SelectedValue), vid.VideoID);
                }

                // footage
                if (!string.IsNullOrWhiteSpace(ddlFootageType.SelectedValue)
                    && ddlFootageType.SelectedValue != selectText)
                {
                    propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                    mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                    MultiPropertyVideo.DeleteMultiPropertyVideo(mp.MultiPropertyID, vid.VideoID);
                    mp.RemoveCache();
                    MultiPropertyVideo.AddMultiPropertyVideo(
                        Convert.ToInt32(
                            ddlFootageType.SelectedValue), vid.VideoID);
                }

                VideoSong.DeleteSongsForVideo(vid.VideoID);

                // song 1

                artst = string.IsNullOrEmpty(txtArtist1.Text.Trim())
                    ? new Artist(ddlArtist1.SelectedValue)
                    : new Artist(txtArtist1.Text);

                if (artst.ArtistID == 0)
                {
                    artst.AltName = FromString.UrlKey(artst.Name);
                    artst.Create();
                }

                if (string.IsNullOrEmpty(txtArtistSong1.Text))
                {
                    sng = new Song(artst.ArtistID, ddlArtistSongs1.SelectedValue);
                }
                else
                {
                    sng = new Song(artst.ArtistID, txtArtistSong1.Text);
                }

                if (sng.SongID == 0)
                {
                    sng.SongKey = FromString.UrlKey(sng.Name);
                    sng.Create();
                }

                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 1);

                // song 2

                if ((ddlArtist2.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist2.SelectedValue)) ||
                    !string.IsNullOrEmpty(txtArtist2.Text))
                {
                    artst = null;
                    sng = null;

                    if (string.IsNullOrEmpty(txtArtist2.Text.Trim()))
                    {
                        artst = new Artist(ddlArtist2.SelectedValue);
                    }
                    else
                    {
                        artst = new Artist(txtArtist2.Text);
                    }

                    if (artst.ArtistID == 0)
                    {
                        artst.AltName = FromString.UrlKey(artst.Name);
                        artst.Create();
                    }

                    if (string.IsNullOrEmpty(txtArtistSong2.Text))
                    {
                        sng = new Song(artst.ArtistID, ddlArtistSongs2.SelectedValue);
                    }
                    else
                    {
                        sng = new Song(artst.ArtistID, txtArtistSong2.Text);
                    }

                    if (sng.SongID == 0)
                    {
                        sng.SongKey = FromString.UrlKey(sng.Name);
                        sng.Create();
                    }

                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 2);

                    if ((ddlArtist3.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist3.SelectedValue)) ||
                        !string.IsNullOrEmpty(txtArtist3.Text))
                    {
                        // song 3

                        artst = null;
                        sng = null;

                        if (string.IsNullOrEmpty(txtArtist3.Text))
                        {
                            artst = new Artist(ddlArtist3.SelectedValue);
                        }
                        else
                        {
                            artst = new Artist(txtArtist3.Text);
                        }

                        if (artst.ArtistID == 0)
                        {
                            artst.AltName = FromString.UrlKey(artst.Name);
                            artst.Create();
                        }

                        if (string.IsNullOrEmpty(txtArtistSong3.Text))
                        {
                            sng = new Song(artst.ArtistID, ddlArtistSongs3.SelectedValue);
                        }
                        else
                        {
                            sng = new Song(artst.ArtistID, txtArtistSong3.Text);
                        }

                        if (sng.SongID == 0)
                        {
                            sng.SongKey = FromString.UrlKey(sng.Name);
                            sng.Create();
                        }

                        VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 3);

                        if ((ddlArtist4.SelectedValue != unknownValue && !string.IsNullOrEmpty(ddlArtist4.SelectedValue)) ||
                            !string.IsNullOrEmpty(txtArtist4.Text))
                        {
                            // song 4

                            artst = null;
                            sng = null;

                            if (string.IsNullOrEmpty(txtArtist4.Text))
                            {
                                artst = new Artist(ddlArtist4.SelectedValue);
                            }
                            else
                            {
                                artst = new Artist(txtArtist4.Text);
                            }

                            if (artst.ArtistID == 0)
                            {
                                artst.AltName = FromString.UrlKey(artst.Name);
                                artst.Create();
                            }

                            if (string.IsNullOrEmpty(txtArtistSong4.Text))
                            {
                                sng = new Song(artst.ArtistID, ddlArtistSongs4.SelectedValue);
                            }
                            else
                            {
                                sng = new Song(artst.ArtistID, txtArtistSong4.Text);
                            }

                            if (sng.SongID == 0)
                            {
                                sng.SongKey = FromString.UrlKey(sng.Name);
                                sng.Create();
                            }

                            VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 4);

                            if ((ddlArtist5.SelectedValue != unknownValue &&
                                 !string.IsNullOrEmpty(ddlArtist5.SelectedValue)) ||
                                !string.IsNullOrEmpty(txtArtist5.Text))
                            {
                                // song 5

                                artst = null;
                                sng = null;

                                if (string.IsNullOrEmpty(txtArtist5.Text))
                                {
                                    artst = new Artist(ddlArtist5.SelectedValue);
                                }
                                else
                                {
                                    artst = new Artist(txtArtist5.Text);
                                }

                                if (artst.ArtistID == 0)
                                {
                                    artst.AltName = FromString.UrlKey(artst.Name);
                                    artst.Create();
                                }

                                if (string.IsNullOrEmpty(txtArtistSong5.Text))
                                {
                                    sng = new Song(artst.ArtistID, ddlArtistSongs5.SelectedValue);
                                }
                                else
                                {
                                    sng = new Song(artst.ArtistID, txtArtistSong5.Text);
                                }

                                if (sng.SongID == 0)
                                {
                                    sng.SongKey = FromString.UrlKey(sng.Name);
                                    sng.Create();
                                }

                                VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 5);

                                if ((ddlArtist6.SelectedValue != unknownValue &&
                                     !string.IsNullOrEmpty(ddlArtist6.SelectedValue)) ||
                                    !string.IsNullOrEmpty(txtArtist6.Text))
                                {
                                    // song 6

                                    artst = null;
                                    sng = null;

                                    if (string.IsNullOrEmpty(txtArtist6.Text))
                                    {
                                        artst = new Artist(ddlArtist6.SelectedValue);
                                    }
                                    else
                                    {
                                        artst = new Artist(txtArtist6.Text);
                                    }

                                    if (artst.ArtistID == 0)
                                    {
                                        artst.AltName = FromString.UrlKey(artst.Name);
                                        artst.Create();
                                    }

                                    if (string.IsNullOrEmpty(txtArtistSong6.Text))
                                    {
                                        sng = new Song(artst.ArtistID, ddlArtistSongs6.SelectedValue);
                                    }
                                    else
                                    {
                                        sng = new Song(artst.ArtistID, txtArtistSong6.Text);
                                    }

                                    if (sng.SongID == 0)
                                    {
                                        sng.SongKey = FromString.UrlKey(sng.Name);
                                        sng.Create();
                                    }

                                    VideoSong.AddVideoSong(sng.SongID, vid.VideoID, 6);
                                }
                            }
                        }
                    }
                }

                //  RefreshLists();

                lblStatus.Text = "OK";
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }

            LoadGrid();
        }
Example #32
0
        private void LoadVideo(string videoKey)
        {
            ClearInput();

            try
            {
                vid = new Video("YT", videoKey);

                litVideo.Text =
                    string.Format(
                        @"<iframe width=""425"" height=""349"" src=""http://www.youtube.com/embed/{0}"" frameborder=""0"" allowfullscreen></iframe>",
                        vid.ProviderKey);

                txtSecondsIn.Text = vid.Intro.ToString();
                txtElasedEnd.Text = vid.LengthFromStart.ToString();
                ddlVideoProvider.SelectedValue = vid.ProviderCode;
                chkEnabled.Checked = vid.IsEnabled;
                ddlVolumeLevel.SelectedValue = vid.VolumeLevel.ToString();
                lblVideoID.Text = vid.VideoID.ToString();

                if (vid.VolumeLevel == 0)
                {
                    ddlVolumeLevel.SelectedValue = "5";
                    chkEnabled.Checked = true;
                }

                var video = new Google.YouTube.Video();

                try
                {
                    var yousettings = new YouTubeRequestSettings("Das Klub", devkey);

                    var yourequest = new YouTubeRequest(yousettings);
                    var url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoKey);

                    video = yourequest.Retrieve<Google.YouTube.Video>(url);
                    txtDuration.Text = video.YouTubeEntry.Duration.Seconds;
                }
                catch (GDataRequestException)
                {
                    vid.IsEnabled = false;
                    vid.Update();
                    litVideo.Text = string.Empty;
                    return;
                }

                if (vid.LengthFromStart == 0)
                {
                    txtElasedEnd.Text = video.YouTubeEntry.Duration.Seconds;
                }

                if (vid.LengthFromStart == 0)
                {
                    txtDuration.Text = video.YouTubeEntry.Duration.Seconds;
                }

                txtUserName.Text = video.Uploader;
                lblVideoID.Text = vid.VideoID.ToString();
                txtVideoKey.Text = video.VideoId;

                // vid type
                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.VIDTP);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                mps = new MultiProperties(propTyp.PropertyTypeID);
                mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); });
                ddlVideoType.DataSource = mps;
                ddlVideoType.DataTextField = "name";
                ddlVideoType.DataValueField = "multiPropertyID";
                ddlVideoType.DataBind();
                ddlVideoType.Items.Insert(0, new ListItem(selectText));
                if (mp.MultiPropertyID != 0)
                    ddlVideoType.SelectedValue = mp.MultiPropertyID.ToString();

                // human
                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.HUMAN);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                mps = new MultiProperties(propTyp.PropertyTypeID);
                mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); });
                ddlHumanType.DataSource = mps;
                ddlHumanType.DataTextField = "name";
                ddlHumanType.DataValueField = "multiPropertyID";
                ddlHumanType.DataBind();
                ddlHumanType.Items.Insert(0, new ListItem(selectText));
                if (mp.MultiPropertyID != 0)
                    ddlHumanType.SelectedValue = mp.MultiPropertyID.ToString();

                // footage
                propTyp = new PropertyType(SiteEnums.PropertyTypeCode.FOOTG);
                mp = new MultiProperty(vid.VideoID, propTyp.PropertyTypeID, SiteEnums.MultiPropertyType.VIDEO);
                mps = new MultiProperties(propTyp.PropertyTypeID);
                mps.Sort(delegate(MultiProperty p1, MultiProperty p2) { return p1.Name.CompareTo(p2.Name); });
                ddlFootageType.DataSource = mps;
                ddlFootageType.DataTextField = "name";
                ddlFootageType.DataValueField = "multiPropertyID";
                ddlFootageType.DataBind();
                ddlFootageType.Items.Insert(0, new ListItem(selectText));
                if (mp.MultiPropertyID != 0)
                    ddlFootageType.SelectedValue = mp.MultiPropertyID.ToString();

                // contest

                var vidInContest = new ContestVideo();

                vidInContest.GetContestVideo(vid.VideoID);

                if (vidInContest.ContestVideoID != 0)
                {
                    ddlContest.SelectedValue = vidInContest.ContestID.ToString();
                }
                else
                    ddlContest.SelectedValue = unknownValue;

                var sngs = new Songs();
                artsngs = new Songs();
                sngs.GetSongsForVideo(vid.VideoID);
                Artist art = null;

                var arts = new Artists();
                arts.GetAll();

                // artists 1
                ddlArtist1.DataSource = arts;
                ddlArtist1.DataTextField = "name";
                ddlArtist1.DataValueField = "name";
                ddlArtist1.DataBind();
                Utilities.General.SortDropDownList(ddlArtist1);
                ddlArtist1.Items.Insert(0, new ListItem(unknownValue));

                // artists 2
                ddlArtist2.DataSource = arts;
                ddlArtist2.DataTextField = "name";
                ddlArtist2.DataValueField = "name";
                ddlArtist2.DataBind();
                Utilities.General.SortDropDownList(ddlArtist2);
                ddlArtist2.Items.Insert(0, new ListItem(unknownValue));

                // artists 3
                ddlArtist3.DataSource = arts;
                ddlArtist3.DataTextField = "name";
                ddlArtist3.DataValueField = "name";
                ddlArtist3.DataBind();
                Utilities.General.SortDropDownList(ddlArtist3);
                ddlArtist3.Items.Insert(0, new ListItem(unknownValue));

                // artists 4
                ddlArtist4.DataSource = arts;
                ddlArtist4.DataTextField = "name";
                ddlArtist4.DataValueField = "name";
                ddlArtist4.DataBind();
                Utilities.General.SortDropDownList(ddlArtist4);
                ddlArtist4.Items.Insert(0, new ListItem(unknownValue));

                // artists 5
                ddlArtist5.DataSource = arts;
                ddlArtist5.DataTextField = "name";
                ddlArtist5.DataValueField = "name";
                ddlArtist5.DataBind();
                Utilities.General.SortDropDownList(ddlArtist5);
                ddlArtist5.Items.Insert(0, new ListItem(unknownValue));

                // artists 6
                ddlArtist6.DataSource = arts;
                ddlArtist6.DataTextField = "name";
                ddlArtist6.DataValueField = "name";
                ddlArtist6.DataBind();
                Utilities.General.SortDropDownList(ddlArtist6);
                ddlArtist6.Items.Insert(0, new ListItem(unknownValue));

                foreach (Song sng in sngs)
                {
                    if (sng.Name == unknownValue || string.IsNullOrEmpty(sng.Name)) continue;

                    // sngrcd.SongDisplay += art.Name + " - " + sng.Name + " " ;

                    if (sng.RankOrder == 0 || sng.RankOrder == 1)
                    {
                        // song 1
                        art = new Artist(sng.ArtistID);
                        ddlArtist1.SelectedValue = art.Name;

                        artsngs = new Songs();
                        artsngs.GetSongsForArtist(art.ArtistID);
                        ddlArtistSongs1.DataSource = artsngs;
                        ddlArtistSongs1.DataTextField = "name";
                        ddlArtistSongs1.DataValueField = "name";
                        ddlArtistSongs1.DataBind();
                        ddlArtistSongs1.Items.Insert(0, new ListItem(unknownValue));
                        Utilities.General.SortDropDownList(ddlArtistSongs1);

                        ddlArtistSongs1.SelectedValue = sng.Name;
                    }
                    else if (sng.RankOrder == 2)
                    {
                        // song 2
                        art = new Artist(sng.ArtistID);
                        ddlArtist2.SelectedValue = art.Name;

                        artsngs = new Songs();
                        artsngs.GetSongsForArtist(art.ArtistID);
                        ddlArtistSongs2.DataSource = artsngs;
                        ddlArtistSongs2.DataTextField = "name";
                        ddlArtistSongs2.DataValueField = "name";
                        ddlArtistSongs2.DataBind();
                        ddlArtistSongs2.Items.Insert(0, new ListItem(unknownValue));
                        Utilities.General.SortDropDownList(ddlArtistSongs2);

                        ddlArtistSongs2.SelectedValue = sng.Name;
                    }
                    else if (sng.RankOrder == 3)
                    {
                        // song 3
                        art = new Artist(sng.ArtistID);
                        ddlArtist3.SelectedValue = art.Name;

                        artsngs = new Songs();
                        artsngs.GetSongsForArtist(art.ArtistID);
                        ddlArtistSongs3.DataSource = artsngs;
                        ddlArtistSongs3.DataTextField = "name";
                        ddlArtistSongs3.DataValueField = "name";
                        ddlArtistSongs3.DataBind();
                        ddlArtistSongs3.Items.Insert(0, new ListItem(unknownValue));
                        Utilities.General.SortDropDownList(ddlArtistSongs3);

                        ddlArtistSongs3.SelectedValue = sng.Name;
                    }
                    else if (sng.RankOrder == 4)
                    {
                        // song 4
                        art = new Artist(sng.ArtistID);
                        ddlArtist4.SelectedValue = art.Name;

                        artsngs = new Songs();
                        artsngs.GetSongsForArtist(art.ArtistID);
                        ddlArtistSongs4.DataSource = artsngs;
                        ddlArtistSongs4.DataTextField = "name";
                        ddlArtistSongs4.DataValueField = "name";
                        ddlArtistSongs4.DataBind();
                        ddlArtistSongs4.Items.Insert(0, new ListItem(unknownValue));
                        Utilities.General.SortDropDownList(ddlArtistSongs4);

                        ddlArtistSongs4.SelectedValue = sng.Name;
                    }
                    else if (sng.RankOrder == 5)
                    {
                        // song 5
                        art = new Artist(sng.ArtistID);
                        ddlArtist5.SelectedValue = art.Name;

                        artsngs = new Songs();
                        artsngs.GetSongsForArtist(art.ArtistID);
                        ddlArtistSongs5.DataSource = artsngs;
                        ddlArtistSongs5.DataTextField = "name";
                        ddlArtistSongs5.DataValueField = "name";
                        ddlArtistSongs5.DataBind();
                        ddlArtistSongs5.Items.Insert(0, new ListItem(unknownValue));
                        Utilities.General.SortDropDownList(ddlArtistSongs5);

                        ddlArtistSongs5.SelectedValue = sng.Name;
                    }
                    else if (sng.RankOrder == 6)
                    {
                        // song 6
                        art = new Artist(sng.ArtistID);
                        ddlArtist6.SelectedValue = art.Name;

                        artsngs = new Songs();
                        artsngs.GetSongsForArtist(art.ArtistID);
                        ddlArtistSongs6.DataSource = artsngs;
                        ddlArtistSongs6.DataTextField = "name";
                        ddlArtistSongs6.DataValueField = "name";
                        ddlArtistSongs6.DataBind();
                        ddlArtistSongs6.Items.Insert(0, new ListItem(unknownValue));
                        Utilities.General.SortDropDownList(ddlArtistSongs6);

                        ddlArtistSongs6.SelectedValue = sng.Name;
                    }
                }

                lblStatus.Text = "OK";
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }
        }
Example #33
0
        private string[] getChannelVideos(int type,string channelUserName,string devKey,string userName, string pass)
        {
            List<string> videos = new List<string>();
            YouTubeRequestSettings settings = new YouTubeRequestSettings("Contentor", devKey, userName, pass);
            YouTubeRequest request = new YouTubeRequest(settings);
            try
            {
                int toplam = 0;
                string q;
                using (WebClient asd = new WebClient())
                {
                    asd.Encoding = Encoding.UTF8;
                    q = asd.DownloadString("http://gdata.youtube.com/feeds/api/users/" + channelUserName + "/uploads?v=2&alt=jsonc&max-results=0");
                }
                string[] adet1 = q.Split(new string[] { "totalItems\":" }, StringSplitOptions.None);
                string[] adet2 = adet1[1].Split(',');
                string adet3 = adet2[0];
                int index = 1;
                for (int i = 1; i <= Convert.ToInt16(adet3) / 50; i++)
                {
                    Uri uri = new Uri("http://gdata.youtube.com/feeds/api/users/" + channelUserName + "/uploads?&max-results=50&start-index=" + index);
                    Feed<Video> videoFeed = request.Get<Video>(uri);
                    foreach (Video entry in videoFeed.Entries)
                    {
                        videos.Add(entry.VideoId);
                    }
                    index += 50;
                }
                toplam = ((Convert.ToInt16(adet3) / 50) * 50) + 1;
                Uri uri2 = new Uri("http://gdata.youtube.com/feeds/api/users/" + channelUserName + "/uploads?&max-results=50&start-index=" + toplam);
                Feed<Video> videoFeed2 = request.Get<Video>(uri2);
                foreach (Video entry in videoFeed2.Entries)
                {
                    videos.Add(entry.VideoId);
                }
            }
            catch
            {
                MessageBox.Show("Sayfa Adında Sorun Var!");
            }
            if (type == 1)
            {
                List<string> checkedVideos = new List<string>();
                foreach (string s in videos)
                {
                    Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/"+s);
                    Video video = request.Retrieve<Video>(videoEntryUrl);
                    if (video.Media != null && video.Media.Rating != null)
                    {
                        checkedVideos.Add(s+" restricted: "+video.Media.Rating.Country);
                    }

                    if (video.IsDraft)
                    {
                        string stateName = video.Status.Name;
                        checkedVideos.Add(s + " not live: "+stateName);
                        /*if (stateName == "processing")
                        {
                            checkedVideos.Add(s + " processing: " + video.Media.Rating.Country);
                        }
                        else if (stateName == "rejected")
                        {
                            checkedVideos.Add(s+" rejected: "+video.Status.Value);
                        }
                        else if (stateName == "failed")
                        {
                            checkedVideos.Add(s+" failed uploading: "+ video.Status.Value);
                        }*/
                    }
                }
                return checkedVideos.ToArray();
            }
                else
            return videos.ToArray();
        }
Example #34
0
        public void Remove(string uploader, string videoID)
        {
            YouTubeRequestSettings settings = new YouTubeRequestSettings("ControlTower", knt_devkey, knt_hadi, knt_hsifresi);
            bool s = true;
            string vidid = "";
            try
            {
                YouTubeRequest request = new YouTubeRequest(settings);
                Uri uri = new Uri(String.Format("http://gdata.YouTube.com/feeds/api/users/{0}/uploads/{1}", uploader, videoID));
                Video a = request.Retrieve<Video>(uri);
                request.Delete(a);
                vidid = a.VideoId;
            }
            catch
            {
                s = false;
            }
            if (s)
                AppendText(richTextBox1, Color.Chocolate, " Silindi: " + videoID + " " + DateTime.Now.ToString());


        }
Example #35
0
 /// <summary>
 /// Creates a track using a YouTube video ID
 /// </summary>
 /// <param name="path">The path of the track</param>
 /// <returns>A TrackData structure representing the YouTube track</returns>
 public static TrackData CreateTrack(string path)
 {
     try
     {
         string id = GetYouTubeID(path);
         YouTubeRequest request = new YouTubeRequest(settings);
         Uri url = new Uri(uriBase + "/feeds/api/videos/" + id);
         Video v = request.Retrieve<Video>(url);
         if (v == null)
         {
             U.L(LogLevel.Warning, "YOUTUBE", "Could not find video with ID '" + id + "'");
             return null;
         }
         return CreateTrack(v);
     }
     catch (Exception e)
     {
         return null;
         //return new TrackData { Title = "Error", Artist = "Error" };
     }
 }
Example #36
0
        public override void control(bot ircbot, BotConfig Conf, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            if (type.Equals("channel") && bot_command == false)
            {
                string text = "";
                if (line.GetUpperBound(0) > 3)
                {
                    text = line[3] + " " + line[4];
                }
                else
                {
                    text = line[3];
                }
                try
                {
                    Regex regex = new Regex("(((https?|ftp|file)://|www\\.)([A-Z0-9.\\-:]{1,})\\.[0-9A-Z?;~&#=\\-_\\./]{2,})", RegexOptions.Compiled | RegexOptions.IgnoreCase);

                    //get the first match
                    MatchCollection matches = regex.Matches(text);

                    foreach (Match match in matches)
                    {
                        string testMatch = match.Value.ToString();
                        if (!testMatch.Contains("://"))
                        {
                            testMatch = "http://" + testMatch;
                        }
                        Uri url = new Uri(testMatch);
                        System.Net.WebRequest req = System.Net.HttpWebRequest.Create(url);
                        req.Method = "HEAD";
                        using (System.Net.WebResponse resp = req.GetResponse())
                        {
                            string[] content_type = resp.ContentType.Split('/');
                            switch (content_type[0])
                            {
                            case "text":
                                WebClient x = new WebClient();
                                x.Encoding = Encoding.UTF8;
                                string          source        = x.DownloadString(url.OriginalString);
                                string          title_regex   = @"(?<=<title.*>)(.*?)(?=</title>)";
                                Regex           title_ex      = new Regex(title_regex, RegexOptions.IgnoreCase);
                                MatchCollection title_matches = title_ex.Matches(source);
                                string          title         = title_matches[0].Value.Trim();
                                if (url.OriginalString.Contains("youtube.com/watch?") && this.Options["parse_youtube"])
                                {
                                    string YouTubeVideoID             = ExtractYouTubeVideoIDFromUrl(url.OriginalString);
                                    Uri    videoEntryUrl              = new Uri(string.Format("https://gdata.youtube.com/feeds/api/videos/{0}", YouTubeVideoID));
                                    YouTubeRequestSettings settings   = new YouTubeRequestSettings("YouTube Video Duration Sample App", developerKey);
                                    YouTubeRequest         yt_request = new YouTubeRequest(settings);
                                    Video    video          = yt_request.Retrieve <Video>(videoEntryUrl);
                                    int      duration       = int.Parse(video.Contents.First().Duration);
                                    string   yt_title       = video.Title;
                                    int      views          = video.ViewCount;
                                    double   rateavg        = video.RatingAverage;
                                    string   uploader       = video.Uploader;
                                    DateTime date           = video.Updated;
                                    string   total_duration = "";
                                    TimeSpan t = TimeSpan.FromSeconds(duration);
                                    if (t.Hours > 0)
                                    {
                                        total_duration += t.Hours.ToString() + "h ";
                                    }
                                    if (t.Minutes > 0)
                                    {
                                        total_duration += t.Minutes.ToString() + "m ";
                                    }
                                    if (t.Seconds > 0)
                                    {
                                        total_duration += t.Seconds.ToString() + "s ";
                                    }
                                    ircbot.sendData("PRIVMSG", channel + " :[Youtube] Title: " + HttpUtility.HtmlDecode(yt_title) + " | Length: " + total_duration.TrimEnd(' ') + " | Views: " + string.Format("{0:#,###0}", views) + " | Rated: " + Math.Round(rateavg, 2).ToString() + "/5.0 | Uploaded By: " + uploader + " on " + date.ToString("yyyy-MM-dd"));
                                }
                                else if (url.OriginalString.Contains("youtu.be") && this.Options["parse_youtube"])
                                {
                                    string[] url_parsed               = url.OriginalString.Split('/');
                                    string   YouTubeVideoID           = url_parsed[url_parsed.GetUpperBound(0)];
                                    Uri      videoEntryUrl            = new Uri(string.Format("https://gdata.youtube.com/feeds/api/videos/{0}", YouTubeVideoID));
                                    YouTubeRequestSettings settings   = new YouTubeRequestSettings("YouTube Video Duration Sample App", developerKey);
                                    YouTubeRequest         yt_request = new YouTubeRequest(settings);
                                    Video    video          = yt_request.Retrieve <Video>(videoEntryUrl);
                                    int      duration       = int.Parse(video.Contents.First().Duration);
                                    string   yt_title       = video.Title;
                                    int      views          = video.ViewCount;
                                    double   rateavg        = video.RatingAverage;
                                    string   uploader       = video.Uploader;
                                    DateTime date           = video.Updated;
                                    string   total_duration = "";
                                    TimeSpan t = TimeSpan.FromSeconds(duration);
                                    if (t.Hours > 0)
                                    {
                                        total_duration += t.Hours.ToString() + "h ";
                                    }
                                    if (t.Minutes > 0)
                                    {
                                        total_duration += t.Minutes.ToString() + "m ";
                                    }
                                    if (t.Seconds > 0)
                                    {
                                        total_duration += t.Seconds.ToString() + "s ";
                                    }
                                    ircbot.sendData("PRIVMSG", channel + " :[Youtube] Title: " + HttpUtility.HtmlDecode(yt_title) + " | Length: " + total_duration.TrimEnd(' ') + " | Views: " + string.Format("{0:#,###0}", views) + " | Rated: " + Math.Round(rateavg, 2).ToString() + "/5.0 | Uploaded By: " + uploader + " on " + date.ToString("yyyy-MM-dd"));
                                }
                                else if ((url.OriginalString.Contains("boards.4chan.org") && url.Segments.GetUpperBound(0) > 2) && this.Options["parse_4chan"])
                                {
                                    string    board = url.Segments[1].TrimEnd('/');
                                    string    uri   = "https://a.4cdn.org/" + board + "/thread/" + url.Segments[3].TrimEnd('/') + ".json";
                                    WebClient chan  = new WebClient();
                                    chan.Encoding = Encoding.UTF8;
                                    var json_data = string.Empty;
                                    json_data = chan.DownloadString(uri);
                                    XmlDocument xmlDoc    = JsonConvert.DeserializeXmlNode(json_data, board + "-" + url.Segments[3].TrimEnd('/'));
                                    XmlNodeList post_list = xmlDoc.SelectNodes(board + "-" + url.Segments[3].TrimEnd('/') + "/posts");
                                    string      thread    = "";
                                    if (!String.IsNullOrEmpty(url.Fragment))
                                    {
                                        thread = url.Fragment.TrimStart('#').TrimStart('p');
                                    }
                                    else
                                    {
                                        thread = url.Segments[3].TrimEnd('/');
                                    }
                                    foreach (XmlNode post in post_list)
                                    {
                                        string post_num = post["no"].InnerText;
                                        if (post_num.Equals(thread))
                                        {
                                            string   date        = post["now"].InnerText;
                                            string   parsed_date = date.Split('(')[0] + " " + date.Split(')')[1];
                                            DateTime post_date   = DateTime.Parse(parsed_date);
                                            TimeSpan difference  = DateTime.UtcNow - post_date;
                                            difference = difference.Subtract(TimeSpan.FromHours(4));
                                            string   total_duration = "";
                                            TimeSpan t = TimeSpan.FromSeconds(difference.TotalSeconds);
                                            if (t.Hours > 0)
                                            {
                                                total_duration += t.Hours.ToString() + "h ";
                                            }
                                            if (t.Minutes > 0)
                                            {
                                                total_duration += t.Minutes.ToString() + "m ";
                                            }
                                            if (t.Seconds > 0)
                                            {
                                                total_duration += t.Seconds.ToString() + "s ";
                                            }
                                            string post_name = "", post_comment = "", tripcode = "", ID = "", subject = "", replies = "", images = "", image_ext = "", image_name = "", image_width = "", image_height = "";
                                            try
                                            {
                                                post_name = post["name"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                post_comment = post["com"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                tripcode = post["trip"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                ID = post["id"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                subject = post["sub"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                replies = post["replies"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                images = post["images"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                image_ext = post["ext"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                image_name = post["tim"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                image_width = post["w"].InnerText;
                                            }
                                            catch { }
                                            try
                                            {
                                                image_height = post["h"].InnerText;
                                            }
                                            catch { }

                                            if (!String.IsNullOrEmpty(ID.Trim()))
                                            {
                                                ID = "[" + ID + "]";
                                            }

                                            string quote = "<span class=\"(.*?)\">(.*?)</span>";
                                            subject = Regex.Replace(subject, quote, "$2");
                                            string post_message = "";
                                            if (!String.IsNullOrEmpty(subject))
                                            {
                                                post_message += "Subject: " + subject + " | ";
                                            }
                                            post_comment = Regex.Replace(post_comment, quote, "$2");
                                            string[] words = post_comment.Split(' ');
                                            if (words.GetUpperBound(0) > 15)
                                            {
                                                post_message += " Comment: ";
                                                for (int i = 0; i < 15; i++)
                                                {
                                                    post_message += words[i] + " ";
                                                }
                                                post_message += "...";
                                            }
                                            else if (!String.IsNullOrEmpty(post_comment))
                                            {
                                                post_message += " Comment: " + post_comment;
                                            }

                                            string[] tmp_post = Regex.Split(post_message, "<br>");
                                            post_message = "";
                                            foreach (string tmp in tmp_post)
                                            {
                                                if (!String.IsNullOrEmpty(tmp.Trim()))
                                                {
                                                    post_message += HttpUtility.HtmlDecode(tmp) + " | ";
                                                }
                                            }

                                            string image_url = "";
                                            if (!String.IsNullOrEmpty(image_name))
                                            {
                                                image_url = "http://images.4chan.org/" + board + "/src/" + image_name + image_ext;
                                            }

                                            if (!String.IsNullOrEmpty(image_url))
                                            {
                                                image_url = " | Posted Image: " + image_url + " (" + image_width + "x" + image_height + ")";
                                            }

                                            if (!String.IsNullOrEmpty(replies))
                                            {
                                                replies = " | Replies: " + replies;
                                            }

                                            if (!String.IsNullOrEmpty(images))
                                            {
                                                images = " | Images: " + images;
                                            }

                                            ircbot.sendData("PRIVMSG", channel + " :[4chan] /" + board + "/ | Posted by: " + post_name + tripcode + ID + " " + total_duration.Trim() + " ago" + replies + images + image_url);
                                            string re = @"<a [^>]+>(.*?)<\/a>(.*?)";
                                            if (!String.IsNullOrEmpty(post_message))
                                            {
                                                ircbot.sendData("PRIVMSG", channel + " :" + Regex.Replace(post_message.Replace("<wbr>", "").Trim().TrimEnd('|').Trim(), re, "$1"));
                                            }
                                            break;
                                        }
                                    }
                                }
                                else if (this.Options["parse_url"])
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :[URL] " + HttpUtility.HtmlDecode(title) + " (" + url.Host + ")");
                                }
                                break;

                            case "image":
                                if (this.Options["parse_image"])
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :[" + resp.ContentType + "] Size: " + ToFileSize(resp.ContentLength));
                                }
                                break;

                            case "video":
                                if (this.Options["parse_video"])
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :[Video] Type: " + content_type[1] + " | Size: " + ToFileSize(resp.ContentLength));
                                }
                                break;

                            case "application":
                                if (this.Options["parse_app"])
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :[Application] Type: " + content_type[1] + " | Size: " + ToFileSize(resp.ContentLength));
                                }
                                break;

                            case "audio":
                                if (this.Options["parse_audio"])
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :[Audio] Type: " + content_type[1] + " | Size: " + ToFileSize(resp.ContentLength));
                                }
                                break;

                            default:
                                if (this.Options["parse_content"])
                                {
                                    ircbot.sendData("PRIVMSG", channel + " :[URL] " + HttpUtility.HtmlDecode(resp.ContentType) + " (" + url.Host + ")");
                                }
                                break;
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }
Example #37
0
        public override void control(bot ircbot, ref IRCConfig conf, int module_id, string[] line, string command, int nick_access, string nick, string channel, bool bot_command, string type)
        {
            string module_name = ircbot.conf.module_config[module_id][0];
            if (type.Equals("channel") && bot_command == false)
            {
                string text = "";
                if(line.GetUpperBound(0) > 3)
                {
                    text = line[3] + " " + line[4];
                }
                else
                {
                    text = line[3];
                }
                try
                {
                    Regex regex = new Regex("(((https?|ftp|file)://|www\\.)([A-Z0-9.-:]{1,})\\.[0-9A-Z?;~&#=\\-_\\./]{2,})", RegexOptions.Compiled | RegexOptions.IgnoreCase);

                    //get the first match
                    MatchCollection matches = regex.Matches(text);

                    foreach (Match match in matches)
                    {
                        string testMatch = match.Value.ToString();
                        if (!testMatch.Contains("://"))
                        {
                            testMatch = "http://" + testMatch;
                        }
                        Uri url = new Uri(testMatch);
                        var request = WebRequest.Create(url);
                        request.Timeout = 5000;
                        using (var response = request.GetResponse())
                        {
                            string[] content_type = response.ContentType.Split('/');
                            switch (content_type[0])
                            {
                                case "text":
                                    WebClient x = new WebClient();
                                    string source = x.DownloadString(url.OriginalString);
                                    string title_regex = @"(?<=<title.*>)(.*?)(?=</title>)";
                                    Regex title_ex = new Regex(title_regex, RegexOptions.IgnoreCase);
                                    MatchCollection title_matches = title_ex.Matches(source);
                                    string title = title_matches[0].Value.Trim();
                                    if (url.OriginalString.Contains("youtube.com/watch?") && ircbot.conf.module_config[module_id][4].Equals("True"))
                                    {
                                        string YouTubeVideoID = ExtractYouTubeVideoIDFromUrl(url.OriginalString);
                                        Uri videoEntryUrl = new Uri(string.Format("https://gdata.youtube.com/feeds/api/videos/{0}", YouTubeVideoID));
                                        YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTube Video Duration Sample App", developerKey);
                                        YouTubeRequest yt_request = new YouTubeRequest(settings);
                                        Video video = yt_request.Retrieve<Video>(videoEntryUrl);
                                        int duration = int.Parse(video.Contents.First().Duration);
                                        string yt_title = video.Title;
                                        int views = video.ViewCount;
                                        double rateavg = video.RatingAverage;
                                        string uploader = video.Uploader;
                                        DateTime date = video.Updated;
                                        string total_duration = "";
                                        TimeSpan t = TimeSpan.FromSeconds(duration);
                                        if (t.Hours > 0)
                                        {
                                            total_duration += t.Hours.ToString() + "h ";
                                        }
                                        if (t.Minutes > 0)
                                        {
                                            total_duration += t.Minutes.ToString() + "m ";
                                        }
                                        if (t.Seconds > 0)
                                        {
                                            total_duration += t.Seconds.ToString() + "s ";
                                        }
                                        ircbot.sendData("PRIVMSG", channel + " :[Youtube] Title: " + HttpUtility.HtmlDecode(yt_title) + " | Length: " + total_duration.TrimEnd(' ') + " | Views: " + string.Format("{0:#,###0}", views) + " | Rated: " + Math.Round(rateavg, 2).ToString() + "/5.0 | Uploaded By: " + uploader + " on " + date.ToString("yyyy-MM-dd"));
                                    }
                                    else if (url.OriginalString.Contains("youtu.be") && ircbot.conf.module_config[module_id][4].Equals("True"))
                                    {
                                        string[] url_parsed = url.OriginalString.Split('/');
                                        string YouTubeVideoID = url_parsed[url_parsed.GetUpperBound(0)];
                                        Uri videoEntryUrl = new Uri(string.Format("https://gdata.youtube.com/feeds/api/videos/{0}", YouTubeVideoID));
                                        YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTube Video Duration Sample App", developerKey);
                                        YouTubeRequest yt_request = new YouTubeRequest(settings);
                                        Video video = yt_request.Retrieve<Video>(videoEntryUrl);
                                        int duration = int.Parse(video.Contents.First().Duration);
                                        string yt_title = video.Title;
                                        int views = video.ViewCount;
                                        double rateavg = video.RatingAverage;
                                        string uploader = video.Uploader;
                                        DateTime date = video.Updated;
                                        string total_duration = "";
                                        TimeSpan t = TimeSpan.FromSeconds(duration);
                                        if (t.Hours > 0)
                                        {
                                            total_duration += t.Hours.ToString() + "h ";
                                        }
                                        if (t.Minutes > 0)
                                        {
                                            total_duration += t.Minutes.ToString() + "m ";
                                        }
                                        if (t.Seconds > 0)
                                        {
                                            total_duration += t.Seconds.ToString() + "s ";
                                        }
                                        ircbot.sendData("PRIVMSG", channel + " :[Youtube] Title: " + HttpUtility.HtmlDecode(yt_title) + " | Length: " + total_duration.TrimEnd(' ') + " | Views: " + string.Format("{0:#,###0}", views) + " | Rated: " + Math.Round(rateavg, 2).ToString() + "/5.0 | Uploaded By: " + uploader + " on " + date.ToString("yyyy-MM-dd"));
                                    }
                                    else if ((url.OriginalString.Contains("boards.4chan.org") && url.Segments.GetUpperBound(0) > 2) && ircbot.conf.module_config[module_id][5].Equals("True"))
                                    {
                                        string board = url.Segments[1].TrimEnd('/');
                                        string uri = "https://api.4chan.org/" + board + "/res/" + url.Segments[3] + ".json";
                                        WebClient chan = new WebClient();
                                        var json_data = string.Empty;
                                        json_data = chan.DownloadString(uri);
                                        XmlDocument xmlDoc = JsonConvert.DeserializeXmlNode(json_data, board + "-" + url.Segments[3]);
                                        XmlNodeList post_list = xmlDoc.SelectNodes(board + "-" + url.Segments[3] + "/posts");
                                        string thread = "";
                                        if (!url.Fragment.Equals(string.Empty))
                                        {
                                            thread = url.Fragment.TrimStart('#').TrimStart('p');
                                        }
                                        else
                                        {
                                            thread = url.Segments[3];
                                        }
                                        foreach (XmlNode post in post_list)
                                        {
                                            string post_num = post["no"].InnerText;
                                            if (post_num.Equals(thread))
                                            {
                                                string date = post["now"].InnerText;
                                                string parsed_date = date.Split('(')[0] + " " + date.Split(')')[1];
                                                DateTime post_date = DateTime.Parse(parsed_date);
                                                TimeSpan difference = DateTime.UtcNow - post_date;
                                                difference = difference.Subtract(TimeSpan.FromHours(4));
                                                string total_duration = "";
                                                TimeSpan t = TimeSpan.FromSeconds(difference.TotalSeconds);
                                                if (t.Hours > 0)
                                                {
                                                    total_duration += t.Hours.ToString() + "h ";
                                                }
                                                if (t.Minutes > 0)
                                                {
                                                    total_duration += t.Minutes.ToString() + "m ";
                                                }
                                                if (t.Seconds > 0)
                                                {
                                                    total_duration += t.Seconds.ToString() + "s ";
                                                }
                                                string post_name = "", post_comment = "", tripcode = "", ID = "", email = "", subject = "", replies = "", images = "", image_ext = "", image_name = "", image_width = "", image_height = "";
                                                try
                                                {
                                                    post_name = post["name"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    post_comment = post["com"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    tripcode = post["trip"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    ID = post["id"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    email = post["email"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    subject = post["sub"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    replies = post["replies"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    images = post["images"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    image_ext = post["ext"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    image_name = post["tim"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    image_width = post["w"].InnerText;
                                                }
                                                catch { }
                                                try
                                                {
                                                    image_height = post["h"].InnerText;
                                                }
                                                catch { }

                                                if (!ID.Trim().Equals(string.Empty))
                                                {
                                                    ID = "[" + ID + "]";
                                                }

                                                string post_message = "";
                                                if (!subject.Equals(string.Empty))
                                                {
                                                    post_message += "Subject: " + subject + " | ";
                                                }
                                                string[] words = post_comment.Split(' ');
                                                if (words.GetUpperBound(0) > 10)
                                                {
                                                    post_message += " Comment: ";
                                                    for (int i = 0; i < 15; i++)
                                                    {
                                                        post_message += words[i] + " ";
                                                    }
                                                    post_message += "...";
                                                }
                                                else if (!post_comment.Equals(string.Empty))
                                                {
                                                    post_message += " Comment: " + post_comment;
                                                }

                                                string[] tmp_post = Regex.Split(post_message, "<br>");
                                                post_message = "";
                                                foreach (string tmp in tmp_post)
                                                {
                                                    if (!tmp.Trim().Equals(string.Empty))
                                                    {
                                                        post_message += HttpUtility.HtmlDecode(tmp) + " | ";
                                                    }
                                                }

                                                string image_url = "";
                                                if (!image_name.Equals(string.Empty))
                                                {
                                                    image_url = "http://images.4chan.org/" + board + "/src/" + image_name + image_ext;
                                                }

                                                if (!image_url.Equals(string.Empty))
                                                {
                                                    image_url = " | Posted Image: " + image_url + " (" + image_width + "x" + image_height + ")";
                                                }

                                                if (!replies.Equals(string.Empty))
                                                {
                                                    replies = " | Replies: " + replies;
                                                }

                                                if (!images.Equals(string.Empty))
                                                {
                                                    images = " | Images: " + images;
                                                }

                                                ircbot.sendData("PRIVMSG", channel + " :[4chan] /" + board + "/ | Posted by: " + post_name + tripcode + ID + " " + total_duration.Trim() + " ago" + replies + images + image_url);
                                                string re = @"<a [^>]+>(.*?)<\/a>(.*?)";
                                                if (!post_message.Equals(string.Empty))
                                                {
                                                    ircbot.sendData("PRIVMSG", channel + " :" + Regex.Replace(post_message.Trim().TrimEnd('|').Trim(), re, "$1"));
                                                }
                                                break;
                                            }
                                        }
                                    }
                                    else if (ircbot.conf.module_config[module_id][3].Equals("True"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :[URL] " + HttpUtility.HtmlDecode(title) + " (" + url.Host.ToLower() + ")");
                                    }
                                    break;
                                case "image":
                                    if (ircbot.conf.module_config[module_id][6].Equals("True"))
                                    {
                                        Image _image = null;
                                        _image = DownloadImage(url.OriginalString);
                                        if (_image != null)
                                        {
                                            ircbot.sendData("PRIVMSG", channel + " :[" + response.ContentType + "] Size: " + ToFileSize(response.ContentLength) + " | Width: " + _image.Width.ToString() + "px | Height: " + _image.Height.ToString() + "px");
                                        }
                                    }
                                    break;
                                case "video":
                                    if (ircbot.conf.module_config[module_id][7].Equals("True"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :[Video] Type: " + content_type[1] + " | Size: " + ToFileSize(response.ContentLength));
                                    }
                                    break;
                                case "application":
                                    if (ircbot.conf.module_config[module_id][8].Equals("True"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :[Application] Type: " + content_type[1] + " | Size: " + ToFileSize(response.ContentLength));
                                    }
                                    break;
                                case "audio":
                                    if (ircbot.conf.module_config[module_id][9].Equals("True"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :[Audio] Type: " + content_type[1] + " | Size: " + ToFileSize(response.ContentLength));
                                    }
                                    break;
                                default:
                                    if (ircbot.conf.module_config[module_id][10].Equals("True"))
                                    {
                                        ircbot.sendData("PRIVMSG", channel + " :[URL] " + HttpUtility.HtmlDecode(response.ContentType) + " (" + url.Host.ToLower() + ")");
                                    }
                                    break;
                            }

                        }
                    }
                }
                catch
                {
                }
            }
        }
Example #38
0
        public Video GetMyVideo(string uploader, string videoID)
        {
                YouTubeRequestSettings settings = new YouTubeRequestSettings("zohaan", "AI39si49oz87UsNqVvW32H5Ve3eJkrdPnctL0Q8kfbpGoqBpowKskuoYSC9iW_6_EVlxzXUpa0oPjZgHTYtXrEfTShULt3d1Dw", "*****@*****.**", "6528yayla");
                YouTubeRequest request = new YouTubeRequest(settings);
                Uri uri = new Uri(String.Format("http://gdata.YouTube.com/feeds/api/users/{0}/uploads/{1}", uploader, videoID));
                return request.Retrieve<Video>(uri);

        }