Esempio n. 1
0
        private void openToolStripMenuItemOpenNStream_Click(object sender, EventArgs e)
        {
            var frm = new NetworkStreamForm();

            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    var scraper = VideoScraperBase.GetScraper(frm.Url);
                    var movie   = new Movie
                    {
                        Description = frm.Url,
                        Url         = frm.Url,
                        Name        = frm.Url,
                        ReleaseDate = DateTime.Now
                    };
                    movie.Links.Add(new MovieLink
                    {
                        DowloadUrl     = frm.Url,
                        Parent         = movie,
                        LinkTitle      = frm.Url,
                        PageSiteID     = scraper.Title,
                        DownloadSiteID = scraper.Title,
                    });
                    this.viewerWindow.LoadVideo(movie, true);
                }
                catch (Exception ex) {
                    KryptonMessageBox.Show(this, ex.Message,
                                           Constants.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 2
0
 protected VideoScraperBase GetScrapper(string url)
 {
     try
     {
         var scraper = VideoScraperBase.GetScraper(url);
         return(scraper);
     }
     catch { return(null); }
 }
Esempio n. 3
0
        public MovieVm QueryMovie(string id, bool updateStat = false)
        {
            using (var db = new MovieFinderEntities())
            {
                try
                {
                    var movie = db.Movies
                                .Include(x => x.MovieLinks)
                                .Where(x => x.UniqueID == id &&
                                       x.MovieLinks.Any(y => y.FailedAttempts < 5))
                                .ToList()
                                .Select(x => new MovieVm {
                        ImageUrl     = String.IsNullOrWhiteSpace(x.ImageLocalUrl) ? x.ImageUrl : imgUrlBuilder.Build(x.ImageLocalUrl),
                        PostedBy     = "Admin",
                        Description  = x.Description,
                        PostedDate   = x.CreateDate.ToShortDateString(),
                        Title        = x.Name,
                        Language     = GetLanguage(x.LanguageCode),
                        ReleasedYear = x.ReleaseDate.Year,
                        Id           = x.UniqueID,
                        Url          = String.Format("{0}/Watch/{1}/{2}/{3}/{4}", confProvider.RootUrl,
                                                     GetLanguage(x.LanguageCode), x.ReleaseDate.Year, x.UniqueID, x.Name),
                        ViewCount = x.ViewCount,
                        LikeCount = x.LikeCount,
                        Links     = x.MovieLinks.Where(z => z.IsWebSupported).Select(y => new VideoLinkVm {
                            HostSite  = y.DownloadSiteID,
                            Title     = ShortenLinkTitle(y.LinkTitle),
                            Url       = VideoScraperBase.GetScraper(y.DowloadUrl).GetFlashUrl(y.DowloadUrl),
                            ID        = y.ID,
                            PartID    = y.PartID,
                            PartIndex = y.PartIndex
                        }).ToList()
                    }).FirstOrDefault();
                    movie.Links.Sort();

                    if (updateStat)
                    {
                        var m = db.Movies.Single(x => x.UniqueID == id);
                        m.ViewCount++;
                        db.SaveChanges();
                    }

                    return(movie);
                }
                catch
                {
                    return(null);
                }
            }
        }
Esempio n. 4
0
        public List <MovieLink> ReadMovieLinks(Movie movie)
        {
            var links = new List <MovieLink>();

            lock (sync)
            {
                using (var cmd = new SQLiteCommand(connection))
                {
                    cmd.CommandText = String.Format("SELECT * FROM MovieLink WHERE MovieID = {0} ORDER BY ID", movie.ID);
                    using (var reader = cmd.ExecuteReader())
                        while (reader.Read())
                        {
                            var url = reader["DownloadUrl"].ToString();
                            if (VideoScraperBase.GetScraper(url) == null)
                            {
                                continue;
                            }
                            int version = MovieDBVersion - 1;
                            try
                            {
                                version = (int)reader["Version"];
                            }
                            catch { }
                            links.Add(new MovieLink
                            {
                                ID             = (int)reader["ID"],
                                DowloadUrl     = url,
                                LinkTitle      = reader["LinkTitle"].ToString(),
                                Parent         = movie,
                                DownloadSiteID = reader["DownloadSiteID"].ToString(),
                                Version        = version
                            });
                        }
                    links.Sort();
                }
            }
            return(links);
        }
Esempio n. 5
0
 public void RemoveLink(string link)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             using (var db = new MovieFinderEntities())
             {
                 var ml = db.MovieLinks.FirstOrDefault(x => x.DowloadUrl == link && x.FailedAttempts <= 3);
                 if (ml != null)
                 {
                     if (VideoScraperBase.ValidateUrl(ml.DowloadUrl) == MovieTube.Client.Scraper.ScraperResult.VideoDoesNotExist)
                     {
                         ml.FailedAttempts  = 5;
                         ml.LastValidatedBy = new Guid();
                         db.SaveChanges();
                     }
                 }
             }
         }
         catch { }
     });
 }
Esempio n. 6
0
 public string ScrapUrl(string url)
 {
     return(VideoScraperBase.ScrapeUrl(url));
 }