MP-TVSeries v4.3.6 Release [2020-01-24] (4 Viewers)

ajs

Development Group
  • Team MediaPortal
  • February 29, 2008
    15,842
    10,865
    Kyiv
    Home Country
    Ukraine Ukraine
    My changes with TLS1.2 seems work with TVDB site, mirrors.xml download well :) but if add TLS1.x instructions to request, not work. I dont know why :)

    --
    WBR, ajs :):whistle::coffee:
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,842
    10,865
    Kyiv
    Home Country
    Ukraine Ukraine
    Also to verify that TheTVdB supports TLS 1.2-Only connections.
    At me ...
    Code:
    (SecurityProtocolType)(0xc0 | 0x300 | 0xc00)
    Not work on TheTVDB site ...
    Code:
    (SecurityProtocolType)0xc00
    Work on TheTVDB site ...
    I don’t know why, but you can check it yourself, replacing everything (SecurityProtocolType)0xc00 to (SecurityProtocolType)(0xc0 | 0x300 | 0xc00)
    PS: I dont have Windows XP, Vista, 8.X ... Only 10 :)
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    It looks like there is some changes to the xml files contained in the zip files e.g.
    http://thetvdb.com/api/<APIKEY>/series/153531/all/en.zip (find attached)

    The first issue is that the language file contained with-in has *zip* in the filename e.g. en.zip.xml, where by previously it was just en.xml.

    The second issue (more breaking), which breaks the current code, is that the XML structure must of changed as the old code assumed that there was a FirstChild.NextSibling, but as the attached debugger shows the value is null:
    Untitled.png

    I'm not sure if these changes are permanent, I can easily make changes but just need to know what it will officially be.
     

    Attachments

    • en.zip.zip
      13.1 KB
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    When saving the XML files I decided to make a change to support both, but if it reverts to old format it will work too e.g.
    Code:
    Helper.SaveXmlCache(filename, x[key].FirstChild.NextSibling ?? x[key].FirstChild )

    Will now look at whats needed to pull down the update zips.
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    Quick update, I added some code to handle redirects, but it looks like the secure updates url tries to redirect again but with no Location header.

    Code:
          string newUrl = null;
          HttpWebRequest request = null;
          HttpWebResponse response = null;
          try
          {
            // .NET 4.0: Use TLS v1.2. Many download sources no longer support the older and now insecure TLS v1.0/1.1 and SSL v3.
            ServicePointManager.SecurityProtocol = ( SecurityProtocolType )0xc00;
            request = (HttpWebRequest)WebRequest.Create(sUrl);
            // Note: some network proxies require the useragent string to be set or they will deny the http request
            // this is true for instance for EVERY thailand internet connection (also needs to be set for banners/episodethumbs and any other http request we send)
            request.UserAgent = Settings.UserAgent;
            request.Timeout = 60000;
            // turn off auto-redirection on the initial request.
            // then we can pull out the header and do the redirection manually by making a new request.
            request.AllowAutoRedirect = false;
            response = (HttpWebResponse)request.GetResponse();
            MPTVSeriesLog.Write( $"Status Code={ response.StatusCode }, Headers={ response.Headers }", MPTVSeriesLog.LogLevel.Debug );
            // check for redirect
            switch ( response.StatusCode )
            {
              case HttpStatusCode.Redirect:
              case HttpStatusCode.MovedPermanently:
              case HttpStatusCode.RedirectKeepVerb:
              case HttpStatusCode.RedirectMethod:
                newUrl = response.Headers["Location"];
                if ( newUrl == null )
                  return null;
                if ( newUrl.IndexOf( "://", System.StringComparison.Ordinal ) == -1 )
                {
                  // doesn't have a URL Schema, meaning it's a relative or absolute URL
                  var u = new Uri( new Uri( sUrl ), newUrl );
                  newUrl = u.ToString();
                }
                // now re-request using new url
                return RetrieveData( newUrl );
                break;
            }
         
            if (response != null) // Get the stream associated with the response.
              return response.GetResponseStream();
          }

    Does anyone know why that is? Known issue?

    The request headers returns:
    Code:
    2019-11-21 16:41:30.371 [DEBG][05]: Retrieving Data from: https://thetvdb.com/api/<apikey>/updates/updates_month.zip
    2019-11-21 16:41:30.475 [DEBG][05]: Status Code='Redirect', Headers=Connection: keep-alive
    x-amzn-RequestId: d399016c-1663-442e-b65c-4e81e0529262
    x-amz-apigw-id: DeqTcH6HvHcFRFw=
    X-Amzn-Trace-Id: Root=1-5dd5bdaf-e52331d2b04543ae92f8ec6e;Sampled=0
    X-Amz-Cf-Pop: SIN52-C2,SIN52-C2
    X-Cache: Hit from cloudfront
    X-Amz-Cf-Id: 3sj8ouyPvxLlCMmXo0lCMuP1LYUFc3ynpoNK78UVfvkA0jg5u3ptfg==
    Age: 7817
    Content-Length: 64
    Content-Type: application/json
    Date: Wed, 20 Nov 2019 22:26:55 GMT
    Via: 1.1 21091692796ba0a5be0a5b521f44889c.cloudfront.net (CloudFront), 1.1 6b0d2463e38d8b2224f25b309fde2ba3.cloudfront.net (CloudFront)
     
    Last edited:

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    Redirection is working for other resources, example below shows redirect from http to https on the mirrors endpoint

    Code:
    2019-11-21 17:09:25.126 [DEBG][05]: Retrieving Data from: http://thetvdb.com/api/<apikey>/mirrors.xml
    2019-11-21 17:09:25.328 [DEBG][05]: Status Code=MovedPermanently, Headers=Connection: keep-alive
    X-Cache: Redirect from cloudfront
    X-Amz-Cf-Pop: SIN52-C2
    X-Amz-Cf-Id: th0rRhoJmgvA1oAqcTm7yU0vhLC2DBZgjCIKTc5rOoEj4deVrxns7A==
    Content-Length: 183
    Content-Type: text/html
    Date: Thu, 21 Nov 2019 06:09:25 GMT
    Location: https://thetvdb.com/api/<apikey>/mirrors.xml
    Server: CloudFront
    Via: 1.1 81ed70dd2a5a6558bf4a599e654fd8e1.cloudfront.net (CloudFront)
    2019-11-21 17:09:25.329 [DEBG][05]: Retrieving Data from: https://thetvdb.com/api/<apikey>/mirrors.xml
    2019-11-21 17:09:25.433 [DEBG][05]: Status Code=OK, Headers=Connection: keep-alive
    x-amzn-RequestId: b5fd359d-8627-442b-b3c8-60460bfe36fc
    x-amz-apigw-id: DdNs2EocvHcFWlg=
    X-Amzn-Trace-Id: Root=1-5dd52985-a42ea8994792045001bbfde1;Sampled=0
    X-Amz-Cf-Pop: SIN52-C2,SIN52-C2
    X-Cache: Hit from cloudfront
    X-Amz-Cf-Id: uD7Hby1uzJywjV32Hkbx0z3hn2sH7XztFF9gmzD4iScZ0bNmv5co_w==
    Age: 9113
    Content-Length: 150
    Content-Type: application/xml
    Date: Wed, 20 Nov 2019 11:54:45 GMT
    Via: 1.1 f651505f69d4004d8a3662c44e02ec6f.cloudfront.net (CloudFront), 1.1 0cd88f29d8c6e29a267867c45efda9a9.cloudfront.net (CloudFront)
    2019-11-21 17:09:25.434 [DEBG][05]: *************************************
    2019-11-21 17:09:25.434 [DEBG][05]: <?xml version="1.0" encoding="UTF-8"?>
    <Mirrors><Mirror><id>1</id><mirrorpath>http://thetvdb.com</mirrorpath><typemask>7</typemask></Mirror></Mirrors>

    But for updates, it tries to redirect again after https but with no location.
     

    Users who are viewing this thread

    Top Bottom