Browse Source

PlayerComponent: resolve plex.direct domains internally

This also enables TLS certificate verification in mpv, like the rest of the app
Rodger Combs 7 years ago
parent
commit
3a65de69b9
1 changed files with 5 additions and 12 deletions
  1. 5 12
      src/player/PlayerComponent.cpp

+ 5 - 12
src/player/PlayerComponent.cpp

@@ -20,6 +20,7 @@
 #include <math.h>
 #include <string.h>
 #include <shared/Paths.h>
+#include <unistd.h>
 
 #if !defined(Q_OS_WIN)
 #include <unistd.h>
@@ -273,16 +274,10 @@ bool PlayerComponent::load(const QString& url, const QVariantMap& options, const
   return true;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-static bool IsPlexDirectURL(const QString& host)
-{
-  return host.endsWith(".plex.direct");
-}
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 static QString ConvertPlexDirectURL(const QString& host)
 {
-    if (!IsPlexDirectURL(host))
+    if (!host.endsWith(".plex.direct"))
         return host;
 
     QString substr = host.left(host.indexOf('.'));
@@ -302,11 +297,10 @@ void PlayerComponent::queueMedia(const QString& url, const QVariantMap& options,
 
   QUrl qurl = url;
   QString host = qurl.host();
-  if (IsPlexDirectURL(host))
-    qurl.setHost(ConvertPlexDirectURL(host));
+  qurl.setHost(ConvertPlexDirectURL(host));
 
   QVariantList command;
-  command << "loadfile" << qurl.toString(QUrl::FullyEncoded);
+  command << "loadfile" << qurl.toString();
   command << "append-play"; // if nothing is playing, play it now, otherwise just enqueue it
 
   QVariantMap extraArgs;
@@ -335,8 +329,7 @@ void PlayerComponent::queueMedia(const QString& url, const QVariantMap& options,
   extraArgs.insert("ad", "");
   extraArgs.insert("vd", "");
 
-  if (IsPlexDirectURL(host))
-    extraArgs.insert("stream-lavf-o", "verifyhost=" + host);
+  extraArgs.insert("stream-lavf-o", "verifyhost=" + host);
 
   command << extraArgs;