[Pending] Utils: DownLoadImage failed when PageRequest need Header "User-Agent" (1 Viewer)


Portal Pro
November 10, 2011
Spain Spain
I'm still not familiar with the peculiarities of the MediaPortal code. My apologies. And even less with GitHub. More apologies. I prefer to answer here

[Obsolete("Method1 is deprecated, please use Method2 instead.")]
This entry point is not used anymore, so is more simple....delete it?

Usually it's good to set some decent timeout like 20 or 30 seconds. At least in Java world defaults can be very long like minutes or even infinite so I would put wReq.Timeout = 20000 after wReq.Accept
You are rigth. This question stuck in my inkwell. Fixed.

Looks good to me

using (Stream response = wReq.GetResponse().GetResponseStream()) ?.
This have been tested with bad results. I prefer to keep it that way, but read again c) from my initial solutions, at the start of this post. (a little joke)

At this time, the code is as follows
    [Obsolete("This entry point is deprecated, please use DownLoadImage(string strURL, string strFile) instead")]    
    public static void DownLoadImage(string strURL, string strFile, System.Drawing.Imaging.ImageFormat imageFormat)
      if ((string.IsNullOrEmpty(strURL)) || (string.IsNullOrEmpty(strFile)))
      DownLoadImage(strURL, strFile);

    /// <summary>
    /// Download a remote image and save it locally.
    /// UserAgent and Accept headers are set for correct request.
    /// Error handling is not responsibility of this method and should be done by method caller as seen fit
    /// see https://forum.team-mediaportal.com/posts/1096988 for more details
    /// </summary>
    /// <param name="strURL">remote image to download</param>
    /// <param name="strFile">local image to save</param>
    public static void DownLoadImage(string strURL, string strFile)
      if ((string.IsNullOrEmpty(strURL)) || (string.IsNullOrEmpty(strFile)))
      Uri uri = new Uri(strURL);
      HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(uri);
      wReq.Proxy.Credentials = CredentialCache.DefaultCredentials;

      wReq.UserAgent = "Mozilla/8.0 (compatible; MSIE 9.0; Windows NT 6.1; .NET CLR 1.0.3705;)";
      wReq.Accept = "*/*";
      wReq.Timeout = 20000;

      using (HttpWebResponse wr = (HttpWebResponse)wReq.GetResponse())
        using (Stream br = wr.GetResponseStream())
          using (FileStream fs = new FileStream(strFile, FileMode.OpenOrCreate, FileAccess.Write))
This code it's just a drop in the ocean, and far from the complexity of developing a mobile driver to manage MediaPortal, but this procedure is used a lot of times.
My only intention is that, this method work efficiently and quickly (of course without errors)

Greetings from Spain!
Last edited:


Portal Pro
November 10, 2011
Spain Spain
It's always good that new blood are around :)
Hi Sebastiii. Sorry, but just read now your post.. My blood its fine (a little of cholesterol) but really... it's not new (far from it) ;) I think my better contribution to this project are about the information of films and tv shows, and perhaps, any isolated method or function needed for some part of the code.
I understand all members here are pro-actives. I am technician engineer, developer (level medium), system administrator (many years) and considerable knowledges about SQL database.
There are a Joke:..
.- Who has some music knowledges?
.- Me, sir.
.- You. Load the piano of the Captain!
I don't have any problems to Load the Piano, or to perform minor tasks.
At this time, i'd like finish these tasks:
One Convert HOWTO post to Wiki (Movie Info Grabbers)
Two: This post



Portal Pro
November 10, 2011
Spain Spain
Hi Sebastiii. At this moment, in Github
Closed with unmerged commits.
So... The last version of the proposed routine is not merge in the code.
I think it should include the last version before closing this post.
I am in your hands to make any improvementes or to make any changes you want to.
Greetings from Spain.


Community Plugin Dev
  • Premium Supporter
  • January 3, 2008
    Russian Federation Russian Federation
    Country flag
    Nice to see new contributions to MP!
    I assume that error with downloading file was with scrapper so why don't we modify scraper itself instead of rewriting mediaportal code? Scrapper in C# so downloading with any webclient/webrequest is possible.
    Also I want to say that setting headers in download method is not so flexible. Some sites could require special headers i.e. "MediaPortal 1.1.0".
    So I think it will be better to have another method with more parameters like headers, gzip encoding and so on.


    Development Group
  • Team MediaPortal
  • November 12, 2007
    France France
    Country flag
    For sure, i'm not the guy to improve it but, you are right it always welcome to see new contributions :)

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    H 1.24.0 MP 1.24 high CPU utilization when 'Keep MediaPortal always on top' option enabled Bugreports 4
    E [solved] No Live TV in MP2.2 Client - Can TEST Successfully in "MediaPortal 2 TV Configuration" utility General 8
    joecrow 1.25.0 Radio Time plugin fails after Resume from Sleep with MP 1.25 Bugreports 10
    M MovingPictures: Hang at retrieving details (connection fails) ? Moving Pictures 23
    Grisu002 Failed to startup - TV Server funktioniert nicht Allgemeines Support- und Diskussionsforum 0
    Dark Eyes TVService locks up or fails to restart on resuming from sleep, and crashes when grabbing EPG Installation, configuration support 7
    T [solved] failed to-startup tvservice Installation, configuration support 1
    B MP 1.23 First time click TV or Recorded TV fails, 2nd ... it will work General Support 5
    W Setup data connection - mySQL connection failed Installation, configuration support 1
    BrownGhost MP-TVSeries, Failed to save xml to cache, and not adding any info to tvseries from tvdb My TVSeries 4
    C Setup failed: 0xfffffff7 Allgemeines Support- und Diskussionsforum 1
    G MP1 TV Server "failed to upgrade the database" using MS Sql Server Installation, configuration support 3
    B TV tuner fails to initialise Watch / Listen Media 0
    P [solved] MP2 fails to install: "Insufficient privileges to start services" General 11
    joecrow Online Videos fails after MP 1.23 upgrade. 1.23 Pre Release 37
    J DVB-S2 card fails to tune? Subchannel count increasing Television (MyTV frontend and TV-Server) 3
    joecrow Scheduled Recordings Failed (MP 1.22) General Support 12
    rexdog [solved] MP2 Instal failing on WIN10 General 2
    porky996t DVB Sat card possibly failed General Support 1
    joecool70 [solved] Installationsprobleme: MP2-Server failed to start Allgemeines Support- und Diskussionsforum 25
    Ralph Holmes [solved] MP2 fails to start after re-boot 2.2 Archive 8
    Holzi [solved] MediaPortal 2 will not install - Failed to start services MediaPortal 2 1
    B [further infos missing] Install failed Exit code: 0xfff7, restarting: No 2.2 Archive 1
    S Display driver failed to start, using microsoft basic display driver instead General Support 23
    Frans Nijhuis [further infos missing] Deleting all TV channels and all channel groups in "MP 2 TV configuration" fails 2.2 Archive 1
    Similar threads

    Top Bottom