Exception in ReadDataFromLink

Apr 4, 2016 at 9:40 PM
hello, i've got this error since few days

03/04/2016 20:59:25 - Exception in ReadDataFromLink (//www.hd-trailers.net/movie/unlocking-the-cage/): ReadDataFromLink 0 0
03/04/2016 20:59:25 - System.InvalidCastException: Impossible d'effectuer un cast d'un objet de type 'System.Net.FileWebRequest' en type 'System.Net.HttpWebRequest'.
à HDTrailersNETDownloader.Program.ReadDataFromLink(String link)
03/04/2016 20:59:25 - Exception in subBetween
03/04/2016 20:59:25 - System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
à HDTrailersNETDownloader.StringFunctions.splitBetween(String source, String from, String to)
Apr 11, 2016 at 2:17 AM
I am getting this same error in the last couple weeks. I am really hoping the developer is still around to support this. I have used it for the past few months, and found it to be amazing. I greatly appreciate the work that has went in to this. If so, I would be more than glad to donate to the cause.

Here is the error in English:

4/10/2016 9:07:22 PM - Exception in ReadDataFromLink (//www.hd-trailers.net/movie/the-bye-bye-man/): ReadDataFromLink 0 0
4/10/2016 9:07:22 PM - System.InvalidCastException: Unable to cast object of type 'System.Net.FileWebRequest' to type 'System.Net.HttpWebRequest'.
at HDTrailersNETDownloader.Program.ReadDataFromLink(String link)
4/10/2016 9:07:22 PM - Exception in GetDownloadUrls (//www.hd-trailers.net/movie/the-bye-bye-man/)
4/10/2016 9:07:22 PM - System.NullReferenceException: Object reference not set to an instance of an object.
at HDTrailersNETDownloader.Program.GetDownloadUrls(String link, String& title)
4/10/2016 9:07:22 PM - Error: No Download URLs found. Skipping...
4/10/2016 9:07:22 PM - Exception in ReadDataFromLink (//www.hd-trailers.net/movie/back-in-the-day/): ReadDataFromLink 0 0
4/10/2016 9:07:22 PM - System.InvalidCastException: Unable to cast object of type 'System.Net.FileWebRequest' to type 'System.Net.HttpWebRequest'.
at HDTrailersNETDownloader.Program.ReadDataFromLink(String link)
4/10/2016 9:07:22 PM - Exception in subBetween
4/10/2016 9:07:22 PM - System.NullReferenceException: Object reference not set to an instance of an object.
at HDTrailersNETDownloader.StringFunctions.splitBetween(String source, String from, String to)
Apr 12, 2016 at 8:15 PM
I'm adding my voice to the list of those who lament that this script has stopped working these past couple of weeks. I imagine it's due to something of a site redesign at HD Trailers, but it would be terrific to get it back in action.
Apr 14, 2016 at 4:28 PM
The problem is with the way the feed data is coming from HD Trailers web site. The url for the movie trailer is missing the "http:" before the movie trailer link. Looks like this was something that was changed a couple of weeks ago.

I have fixed the issue on my local copy for the 1 feed, unfortunately the source code is missing at least 1 file. Hopefully the original developer is still reading this forum and he can make the required changes.
Coordinator
Apr 15, 2016 at 2:11 AM
Let me take a look. Probably won't get to it until next week. Let me track down the source as well. I thought I had uploaded the latest version at the time but may have missed a couple of files.
Apr 15, 2016 at 2:59 AM
Edited Apr 15, 2016 at 3:04 AM
If it helps, this is what I did to fix the issue on my end.....

File: Program.cs
Function: static NameValueCollection GetDownloadUrls(string link, ref string title)

Code
// now find the poster url
// look for first 'Link to Catalog' then pick the src attribute from the first img tag

tempString = StringFunctions.subStrBetween(data, "<div class=\"posterBlock\">", "</div>");
tempString = tempString.Substring(tempString.IndexOf("<img "));
tempString = tempString.Substring(tempString.IndexOf("src=\"") + 5);
tempString = tempString.Substring(0, tempString.IndexOf("\""));

 // New code added Start
 tempString = "http:" + tempString;
 // New code added End

 nvc.Add("poster", tempString);
 return nvc;
=========================================
File: fetcher_HDTrailersNetRss2.cs
Function: public override void LoadItem(MovieItem mi)

Code:
public override void LoadItem(MovieItem mi)
{
    try
    {
        string url;
        string trailerString;

        // New code added Start
        mi.url = "http:" + mi.url;
        // New code added End

        string data = Program.ReadDataFromLink(mi.url);

As a seperate issue, I noticed that the system would not download Teaser trailers, I would get a response stating that it is not a trailer. To fix this, I changed the IF statement to not include Teaser trailers when checking if a trailer is valid or not:

File: Program.cs
Function: static void ProcessFeedItem(string title, MovieItem link)
//            if ((config.TrailersOnly) && (!title.Contains("Trailer")))
if ((config.TrailersOnly) && ((!title.Contains("Trailer") && (!title.Contains("Teaser")))))
{
    log.WriteLine("Title not a trailer. Skipping...");
    AddToEmailSummary(title + " (" + qualPreference + ") : Title not a trailer. Skipping...");
    return;
}


Note: the + should be "+" symbol, not sure why the editor is changing it.
Apr 20, 2016 at 9:44 PM
I'm very grateful to you guys for taking the time to track this down and help fix it. Thank you very much.
Apr 21, 2016 at 6:09 PM
Looks like HD Trailers made more changes to their stream. The movie download links now have the "HTTP:" prefix attached to them. The poster link is still missing.
Coordinator
Apr 22, 2016 at 12:03 AM
Glad you were able to fix it SinFire. I have located the complete source and have corrected the issue with the RSS feed. I will upload the code when I can get SVN to work correctly again.
Apr 22, 2016 at 12:31 AM
Great, thanks for the quick response.
Coordinator
Apr 22, 2016 at 1:09 AM
Been so long since I used SVN that I ahve to figure out how to upload again <grin>.

I am just glad that people still find this useful. Toland, HD-Trailers.Net has been very supportive over the years. This time, when I asked, he pointed out the changes he had to make. and he has been responsive to requests for improvements.
The change in behavior you observed was a result of me asking what changed and him correcting the problem from their side.
Take Care
Apr 22, 2016 at 1:20 AM
I have been running this script for a couple of years, but all the trailers just go to a directory on my server. I haven't gotten around to using them yet, but at least it saves me time from having to search and download them manually.

That is great that you have a contact at HDTrailers. It helps out when you need to debug issues.

With the current system, they are still missing the HTTP prefix on the poster download link.

Thanks,
Steve
Apr 24, 2016 at 3:15 PM
Sorry if this is a daft question but ijourneaux, am I right in thinking that you have not yet uploaded this change? No worries if not at all, I just wanted to be sure that I wasn't being an idiot.
Apr 24, 2016 at 3:31 PM
Looks like v2.4.5 was uploaded yesterday in beta mode. Should be good to download and test to see if everything is working as expected
Apr 24, 2016 at 4:49 PM
Ah yes, so I was being an idiot. No big surprise there. I have run the script again after copying over my old config folder and this error is gone and even as I type I can see the trailer download ticking along in the background CMD window.

Immense thanks for your efforts on this one, chaps. Very nice to have trailers back up and running!

PS - should anything go wrong (which looks vanishingly unlikely at this point) I will edit this post and report on it.
Coordinator
Apr 28, 2016 at 3:09 AM
Thanks to everyone (especially ijourneaux) who has worked to keep this going over the years. Absolutely amazing!
Coordinator
Apr 29, 2016 at 3:30 AM
The changes to the source have not been uploaded yet as SVN on Codeplex is broken. It is good to see BrianAz is still around as he is the one that has to authorize the conversion to GIT.

And Thank you BrianAZ for starting this project
Apr 29, 2016 at 5:38 PM
Great, let me know when you do get the latest code checked in.



-- Steve