NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Other Clients Old Stuff (legacy) NextPVR Enhanced Web Admin (NEWA) v
« Previous 1 … 5 6 7 8 9 … 47 Next »
Changes to App_Code\Download.aspx.cs for fanart

 
  • 0 Vote(s) - 0 Average
Changes to App_Code\Download.aspx.cs for fanart
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#1
2014-03-29, 08:01 PM
I needed a way to get the show images from the server in a Win 8 metro app on a client machine. Nothing I tried worked (seriously walled garden) so I looked into using public/Download.ashx but I would get a E_NETWORK_ERROR in my app because of the way the response/content-type was being written from the web service.

I changed "case FanArt:" to work the way I needed it. Images are now displayed inline in IE instead of being downloaded and displayed in a separate app.

Code:
case (int)InternalFiles.FanArt:
    /*
    Can be used to download any image.
    Supports the following variables (trailing backslash not required):
        [[DataDir]] = NPVR data directory.
        [[MediaDir]] = NPVR data directory + "Media\\"
        [[MediaShowsDir]] = NPVR data directory + "Media\\Shows\\"
        
    Notes:
        DO NOT INCLUDE FILE EXTENSIONS... the request will automatically check for ".png" then for ".jpg".
        Filenames should already be parsed to remove invalid filename characters and trimmed.
        If no image is found, it will return "no_album_art.jpg".
        
    Example:
        // Download the image for the show "2 Broke Girls *" from Media\Shows:
        {
            string showName = "2 Broke Girls *";
            string url = @"http://localhost:8866/public/download.ashx/-11,1?[[MediaShowsDir]]" + string.Join(string.Empty, rName.Split(System.IO.Path.GetInvalidFileNameChars())).Trim();
            // Download the image from "url"
        }
    */
    fileName = path.Replace("[[DataDir]]", SettingsHelper.GetInstance().GetDataDirectory());
    fileName = fileName.Replace("[[MediaDir]]", SettingsHelper.GetInstance().GetDataDirectory() + "Media\\");
    fileName = fileName.Replace("[[MediaShowsDir]]", SettingsHelper.GetInstance().GetDataDirectory() + "Media\\Shows\\");
    if (File.Exists(fileName + ".png"))
    {
        fileName += ".png";
        Response.ContentType = "image/png";
    }
    else
    {
        if (File.Exists(fileName + ".jpg"))
            fileName += ".jpg";
        else
        fileName = SettingsHelper.GetInstance().GetDataDirectory() + "web\\themes2\\common\\graphics\\no_album_art.jpg";
        
        Response.ContentType = "image/jpeg";
    }
    Image fanArtImg = new Bitmap(fileName);
    ImageConverter fanArtConverter = new ImageConverter();
    Response.BinaryWrite((byte[])fanArtConverter.ConvertTo(fanArtImg, typeof(byte[])));
    Response.End();
    fanArtImg.Dispose();
    seekable = false;
    break;
UncleJohnsBand
Offline

Posting Freak

U.S.A.
Posts: 5,643
Threads: 258
Joined: Feb 2005
#2
2014-03-30, 01:37 PM
Ok. I'll check it out.
Intel Core i7 @ 4.00GHz Skylake 14nm
ASUSTeK COMPUTER INC. Z170-DELUXE
Windows 10 Pro x64
PVR Software: NPVR 5.1.1
SiliconDust HDHomeRun HDHR5-4US Connect Quatro 4 Channel Tuner
Roku Ultra
2 PCH A-100's
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Cannot find logon.aspx ?? mattyb 2 1,619 2012-09-08, 04:29 AM
Last Post: UncleJohnsBand
  Streaming fails in Guide2.aspx grahamw 3 2,111 2011-04-01, 01:28 AM
Last Post: UncleJohnsBand
  Show Coloring Guide in Guide.aspx whurlston 3 1,799 2010-01-09, 06:27 PM
Last Post: UncleJohnsBand
  EWA Download link request.... psycik 17 5,134 2009-11-18, 03:40 AM
Last Post: UncleJohnsBand
  admin(2).aspx times out medic29 2 1,949 2009-10-12, 01:53 AM
Last Post: medic29
  change in guide.aspx format medic29 1 1,390 2009-03-01, 05:55 AM
Last Post: UncleJohnsBand
  Page not found when attempting to download long shows medic29 7 2,447 2008-12-19, 01:22 AM
Last Post: UncleJohnsBand
  wishlist: download links shorter.... psycik 4 2,396 2008-06-23, 06:03 PM
Last Post: fuzzweed
  Request: Download/Stream URLs psycik 5 2,568 2007-03-01, 12:23 AM
Last Post: psycik
  Download All from the Music Library roebel 14 4,377 2006-12-11, 02:17 AM
Last Post: UncleJohnsBand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode