-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjfflix.ps1
56 lines (43 loc) · 2.32 KB
/
jfflix.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Set Jellyfin server URL and API key
$jellyfinUrl = "http://localhost:8096"
$jellyfinApiKey = ""
# Set The Movie DB API key
$tmdbApiKey = ""
# Get all movies and shows from Jellyfin library
$allItemsUrl = "$jellyfinUrl/Items?api_key=$jellyfinApiKey&Recursive=true&IncludeItemTypes=Movie,Series"
$allItemsResponse = Invoke-RestMethod -Method Get -Uri $allItemsUrl
# Loop through all items and get their titles
foreach ($item in $allItemsResponse.Items) {
$title = $item.Name
# Check if item is a movie or a show
if ($item.Type -eq "Movie") {
# Search The Movie DB for the movie
$searchUrl = "https://api.themoviedb.org/3/search/movie?api_key=$tmdbApiKey&query=$title"
$searchResponse = Invoke-RestMethod -Method Get -Uri $searchUrl
# Check if any results were found
if ($searchResponse.total_results -gt 0) {
# Check if the movie is available on Netflix
$movieId = $searchResponse.results[0].id
$movieDetailsUrl = "https://api.themoviedb.org/3/movie/$movieId?api_key=$tmdbApiKey&append_to_response=watch/providers"
$movieDetailsResponse = Invoke-RestMethod -Method Get -Uri $movieDetailsUrl
if ($movieDetailsResponse["watch/providers"].results.netflix -ne $null) {
Write-Host "Movie '$title' is available on Netflix"
}
}
}
elseif ($item.Type -eq "Series") {
# Search The Movie DB for the show
$searchUrl = "https://api.themoviedb.org/3/search/tv?api_key=$tmdbApiKey&query=$title"
$searchResponse = Invoke-RestMethod -Method Get -Uri $searchUrl
# Check if any results were found
if ($searchResponse.total_results -gt 0) {
# Check if the show is available on Netflix
$showId = $searchResponse.results[0].id
$showDetailsUrl = "https://api.themoviedb.org/3/tv/$showId?api_key=$tmdbApiKey&append_to_response=watch/providers"
$showDetailsResponse = Invoke-RestMethod -Method Get -Uri $showDetailsUrl
if ($showDetailsResponse["watch/providers"].results.netflix -ne $null) {
Write-Host "Show '$title' is available on Netflix"
}
}
}
}