-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (74 loc) · 1.81 KB
/
index.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const apiKeyTMDB = "6916ab0589053145100ff85e25d72ce5";
const apiKeySonarr = "6ea11f4568d34aa7b0c96148570b5c40";
const apiKeyRadarr = "2a28a93e5ed24a89a6c81ed2c46eda72";
function sonarrIndex() {
fetch(`http://localhost:8989/api/series?apikey=${apiKeySonarr}`)
.then((response) => {
return response.json();
})
.then((series) => {
series.forEach((serie) => {
fetch(
`https://api.themoviedb.org/3/find/${serie.tvdbId}?api_key=${apiKeyTMDB}&external_source=tvdb_id`
)
.then((response) => {
return response.json();
})
.then((data) => {
console.log(serie.title);
if (data.tv_results.length == 1) {
// console.log(data.tv_results[0]);
console.log(
data.tv_results[0].name +
", " +
data.tv_results[0].original_language
);
} else {
// console.log(data.tv_results);
}
console.log("");
})
.catch((err) => {
console.log(err);
});
});
})
.catch((err) => {
console.log(err);
});
}
function radarrIndex() {
fetch(`http://localhost:7878/api/v3/movie?apikey=${apiKeyRadarr}`)
.then((response) => {
return response.json();
})
.then((movies) => {
movies.forEach((movie) => {
// matchIdToTMDB(movie.title, movie.tvdbId, "tmdb", "movie");
fetch(
`https://api.themoviedb.org/3/movie/${movie.tmdbId}?api_key=${apiKeyTMDB}&external_source=tvdb_id`
)
.then((response) => {
return response.json();
})
.then((data) => {
console.log(movie.title);
console.log(
data.title +
", " +
data.original_language
);
console.log("");
})
.catch((err) => {
console.log(err);
});
});
})
.catch((err) => {
console.log(err);
});
}
// matchIdToTMDB("393205", "tvdb");
// sonarrIndex();
radarrIndex();