Browse Source

fix #1250 集数排序

magicblack 5 months ago
parent
commit
f1279a4dd2
1 changed files with 20 additions and 2 deletions
  1. 20 2
      application/common/model/Collect.php

+ 20 - 2
application/common/model/Collect.php

@@ -248,7 +248,9 @@ class Collect extends Base {
             if(isset($video->dl->dd) && $count=count($video->dl->dd)){
             if(isset($video->dl->dd) && $count=count($video->dl->dd)){
                 for($i=0; $i<$count; $i++){
                 for($i=0; $i<$count; $i++){
                     $array_from[$i] = (string)$video->dl->dd[$i]['flag'];
                     $array_from[$i] = (string)$video->dl->dd[$i]['flag'];
-                    $array_url[$i] = $this->vod_xml_replace((string)$video->dl->dd[$i]);
+                    $urls = explode('#', $this->vod_xml_replace((string)$video->dl->dd[$i]));
+                    $sorted_urls = $this->sortPlayUrls($urls);
+                    $array_url[$i] = implode('#', $sorted_urls);
                     $array_server[$i] = 'no';
                     $array_server[$i] = 'no';
                     $array_note[$i] = '';
                     $array_note[$i] = '';
 
 
@@ -358,7 +360,9 @@ class Collect extends Base {
                 //videolist|list播放列表不同
                 //videolist|list播放列表不同
                 foreach ($v['dl'] as $k2 => $v2) {
                 foreach ($v['dl'] as $k2 => $v2) {
                     $array_from[] = $k2;
                     $array_from[] = $k2;
-                    $array_url[] = $v2;
+                    $urls = explode('#', $v2);
+                    $sorted_urls = $this->sortPlayUrls($urls);
+                    $array_url[] = implode('#', $sorted_urls);
                     $array_server[] = 'no';
                     $array_server[] = 'no';
                     $array_note[] = '';
                     $array_note[] = '';
                 }
                 }
@@ -385,6 +389,20 @@ class Collect extends Base {
         return $res;
         return $res;
     }
     }
 
 
+    private function sortPlayUrls($urls) {
+        $sorted = [];
+        foreach ($urls as $url) {
+            if (preg_match('/(?:第|EP|E)?(\d+)(?:集|话|回)?/', $url, $matches)) {
+                $episode = (int)$matches[1];
+                $sorted[$episode] = $url;
+            } else {
+                $sorted[] = $url;
+            }
+        }
+        ksort($sorted);
+        return array_values($sorted);
+    }
+
     /**
     /**
      * 同步图片
      * 同步图片
      *
      *