Commit 92f7c430 authored by Tristan Smith's avatar Tristan Smith
Browse files

Fixed some things, worked on title extraction

*removed some breaks
*relocated some breaks to work better
*basic title extraction works (getTitle() in ClassTest)
parent efa0af9e
......@@ -16,8 +16,8 @@ namespace Something
static void Main(string[] args)
{
// const string url = @"https://videos.toypics.net/view/3300/butt-bouncing-on-chance~/"; // dev
const string url = @"https://videos.toypics.net/Junee/public/"; // dev
const string url = @"https://videos.toypics.net/view/3300/butt-bouncing-on-chance~/"; // dev
// const string url = @"https://videos.toypics.net/Junee/public/"; // dev
try
{
......@@ -38,23 +38,25 @@ namespace Something
Uri video = getVidUri(link, @".toypics.net/flvideo/", ".mp4"); //get raw video link
using (WebClient dl = new WebClient())
{
dl.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); //dev
dl.DownloadFileAsync(video, "video.mp4"); //dev
//dl.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); //dev
//dl.DownloadFileAsync(video, @"video.mp4"); //dev
Console.WriteLine("Done"); //dev
Console.WriteLine(getTitle(url));
}
}
catch (Exception ex)
catch (WebException)
{
Console.WriteLine(ex);
throw;
}
break; //break out of the foreach loop, only one javascript player on each page but there are multiple <script> tags , so its useless to continue once we find the player
}
break; //break out of the foreach loop, only one javascript player on each page but there are multiple <script> tags , so its useless to continue once we find the player
}
}
#endregion
// user profile download
#region user profile download
if (Regex.IsMatch(url, "(/public/)")) // /public/ is unique to user profiles
{
foreach (HtmlNode videolink in doc.DocumentNode.SelectNodes("//p[@class='video-entry-title']/a")) //loop through every <a> tag page link
......@@ -66,10 +68,11 @@ namespace Something
}
}
}
#endregion
}
catch (Exception ex)
{
Console.WriteLine("Error happened and shit | {0}", ex); // dev
Console.WriteLine("There was an error somewhere; {0}", ex.Message);
}
Console.ReadKey();
......@@ -126,8 +129,16 @@ namespace Something
Console.WriteLine(ex);
}
}
break; //break out of the foreach loop, only one javascript player on each page but there are multiple <script> tags , so its useless to continue once we find the player
}
}
private static string getTitle(string page)
{
HtmlWeb hw = new HtmlWeb();// HtmlAgilityPack
HtmlDocument doc = hw.Load(page);// load uri
string link = doc.DocumentNode.SelectSingleNode("//*[@id='view-video-content']/*[@class='section bg2']/*[@class='hd']").InnerText; // the true title is stored in a <div> tag with the class of hd-l (HD-L) but i keep getting an exception if i try /*[@class='hd-l']
//for now im just going to trim the returned string
return link.Trim();
}
}
}
......@@ -103,7 +103,6 @@ namespace ToyPics
Console.WriteLine(ex);
}
}
break; //break out of the foreach loop, only one javascript player on each page but there are multiple <script> tags , so its useless to continue once we find the player
}
}
}
......
......@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ToyPics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("ToyPicsClass")]
[assembly: AssemblyDescription("Module Based Class")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ToyPics")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCompany("Megic LTD")]
[assembly: AssemblyProduct("ToyPicsClass")]
[assembly: AssemblyCopyright("Copyright © Megic LTD 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment