浏览代码

Merge pull request #1774 from jessehickman/patch-6

Add direct Sonarr/Radarr/Lidarr button link to calendar modal
causefx 4 年之前
父节点
当前提交
e6298f8c54
共有 4 个文件被更改,包括 36 次插入4 次删除
  1. 9 1
      api/homepage/lidarr.php
  2. 9 1
      api/homepage/radarr.php
  3. 9 1
      api/homepage/sonarr.php
  4. 9 1
      js/functions.js

+ 9 - 1
api/homepage/lidarr.php

@@ -237,6 +237,12 @@ trait LidarrHomepageItem
 					$fanart = str_replace('http://', 'https://', $image['url']);
 				}
 			}
+			$href = "";
+			if (!empty($this->config['lidarrURL'])){
+				$href_arr = explode(',',$this->config['lidarrURL']);
+				$href = reset($href_arr) . '/artist/' . $child['artist']['foreignArtistId'];
+				$href = str_replace("//artist/","/artist/",$href);
+			}
 			$details = array(
 				"seasonCount" => '',
 				"status" => '',
@@ -252,6 +258,8 @@ trait LidarrHomepageItem
 				"videoCodec" => "unknown",
 				"size" => "unknown",
 				"genres" => $child['genres'],
+				"href" => strtolower($href),
+				"icon" => "/plugins/images/tabs/lidarr.png",
 			);
 			array_push($gotCalendar, array(
 				"id" => "Lidarr-" . $number . "-" . $i,
@@ -272,4 +280,4 @@ trait LidarrHomepageItem
 		return false;
 	}
 	
-}
+}

+ 9 - 1
api/homepage/radarr.php

@@ -322,6 +322,12 @@ trait RadarrHomepageItem
 					}
 				}
 				$alternativeTitles = empty($alternativeTitles) ? "" : substr($alternativeTitles, 0, -2);
+				$href = "";
+				if (!empty($this->config['radarrURL'])){
+					$href_arr = explode(',',$this->config['radarrURL']);
+					$href = reset($href_arr) . '/movie/' . $movieID;
+					$href = str_replace("//movie/","/movie/",$href);
+				}
 				$details = array(
 					"topTitle" => $movieName,
 					"bottomTitle" => $alternativeTitles,
@@ -338,6 +344,8 @@ trait RadarrHomepageItem
 					"genres" => $child['genres'],
 					"year" => $child['year'] ?? '',
 					"studio" => $child['studio'] ?? '',
+					"href" => strtolower($href),
+					"icon" => "/plugins/images/tabs/radarr.png",
 				);
 				array_push($gotCalendar, array(
 					"id" => "Radarr-" . $number . "-" . $i,
@@ -358,4 +366,4 @@ trait RadarrHomepageItem
 		}
 		return false;
 	}
-}
+}

+ 9 - 1
api/homepage/sonarr.php

@@ -289,6 +289,12 @@ trait SonarrHomepageItem
 				}
 			}
 			$bottomTitle = 'S' . sprintf("%02d", $child['seasonNumber']) . 'E' . sprintf("%02d", $child['episodeNumber']) . ' - ' . $child['title'];
+			$href = "";
+			if (!empty($this->config['sonarrURL'])){
+				$href_arr = explode(',',$this->config['sonarrURL']);
+				$href = reset($href_arr) . '/series/' . preg_replace('/[^A-Za-z0-9. -]/', '', preg_replace('/[[:space:]]+/', '-', $seriesName));
+				$href = str_replace("//series/","/series/",$href);
+			}
 			$details = array(
 				"seasonCount" => $child['series']['seasonCount'] ?? isset($child['series']['seasons']) ? count($child['series']['seasons']) : 0,
 				"status" => $child['series']['status'],
@@ -304,6 +310,8 @@ trait SonarrHomepageItem
 				"videoCodec" => $child["hasFile"] && isset($child['episodeFile']['mediaInfo']) ? $child['episodeFile']['mediaInfo']['videoCodec'] : "unknown",
 				"size" => $child["hasFile"] && isset($child['episodeFile']['size']) ? $child['episodeFile']['size'] : "unknown",
 				"genres" => $child['series']['genres'],
+				"href" => strtolower($href),
+				"icon" => "/plugins/images/tabs/sonarr.png",
 			);
 			array_push($gotCalendar, array(
 				"id" => "Sonarr-" . $number . "-" . $i,
@@ -322,4 +330,4 @@ trait SonarrHomepageItem
 		}
 		return false;
 	}
-}
+}

+ 9 - 1
js/functions.js

@@ -6957,6 +6957,14 @@ function buildYoutubeLink(title){
 		`;
 	}
 }
+function buildPVRLink(href, ico){
+	if (href){
+		var styleOverride = `width:55px;height:44px;background-image: url(${ico});background-repeat:no-repeat;background-size:25px;background-position:center;`;
+		return `
+		<div class="btn btn-inverse waves-effect waves-light" type="button" onclick="window.open('${href}')" style="${styleOverride}"></div>
+		`;
+	} 
+}
 function buildCalendarMetadata(array){
 	var metadata = '';
 	var genres = '';
@@ -6983,7 +6991,7 @@ function buildCalendarMetadata(array){
 	                <h2 class="m-b-0 font-medium pull-right text-right">
 						`+array.topTitle+`<button type="button" class="btn bg-org btn-circle close-popup m-l-10"><i class="fa fa-times"></i> </button><br>
 						<small class="m-t-0 text-white">`+array.bottomTitle+`</small><br>
-						`+buildYoutubeLink(array.topTitle)+`
+						`+buildPVRLink(array.href, array.icon)+buildYoutubeLink(array.topTitle)+`
 					</h2>
 	            </div>
 				<div class="genre-list p-10">`+genres+`</div>