-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
391 lines (239 loc) · 11.6 KB
/
main.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
// var frames = document.getElementsByTagName('iframe');
// for (var frame of frames) {
// frame.setAttribute("sandbox", "allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-scripts allow-top-navigation allow-forms");
// }
// window.onload = function(){
// var button = document.getElementsByName("sandbox")[0]
// var iframe = document.getElementsByName("framez")[0]
// button.addEventListener('click',sndbx,false);
// function sndbx(){
// var nibba = document.getElementById("framez").src;
// if(iframe.sandbox == 'allow-forms allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation'){
// document.getElementById("framez").removeAttribute("sandbox");
// }
// frames['framez'].location.href=nibba;
// iframe.sandbox = 'allow-forms allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation';
// }
// }
function getMovieSuggestions() {
const movieName = document.getElementById('movieName').value;
const apiKey = '69a6237ce6938d2fb74092f8ff3a8f16'; // Replace with your TMDb API key
if (movieName.trim() === '') {
clearMovieSuggestions();
return;
}
fetch(`https://api.themoviedb.org/3/search/movie?api_key=${apiKey}&query=${encodeURIComponent(movieName)}`)
.then(response => response.json())
.then(data => {
const movieSuggestionsList = document.getElementById('movieSuggestions');
movieSuggestionsList.innerHTML = '';
if (data.results && data.results.length > 0) {
data.results.slice(0, 5).forEach(result => {
const listItem = document.createElement('li');
listItem.textContent = result.title;
listItem.onclick = function () {
document.getElementById('movieName').value = result.title;
clearMovieSuggestions();
};
movieSuggestionsList.appendChild(listItem);
});
}
})
.catch(error => {
console.error('Error fetching movie suggestions:', error);
clearMovieSuggestions();
});
}
function searchMovie() {
const movieName = document.getElementById('movieName').value;
const apiKey = '69a6237ce6938d2fb74092f8ff3a8f16';
fetch(`https://api.themoviedb.org/3/search/movie?api_key=${apiKey}&query=${encodeURIComponent(movieName)}`)
.then(response => response.json())
.then(data => {
const movieResultElement = document.getElementById('movieResult');
const movieCopyButton = document.getElementById('movieCopyButton');
if (data.results && data.results.length > 0) {
const movieTmdbId = data.results[0].id;
const firstMovieUrl = `https://vidsrc.xyz/embed/movie/${movieTmdbId}`;
const secondMovieUrl = `https://vidsrc.to/embed/movie/${movieTmdbId}`;
const firstIframe = document.createElement('iframe');
firstIframe.src = firstMovieUrl;
firstIframe.allowfullscreen = true;
const secondIframe = document.createElement('iframe');
secondIframe.src = secondMovieUrl;
secondIframe.allowfullscreen = true;
movieResultElement.innerHTML = '';
const firstLinkElement = document.createElement('a');
firstLinkElement.href = firstMovieUrl;
firstLinkElement.target = '_blank';
firstLinkElement.textContent = "Generated URL 1: " + firstMovieUrl;
const secondLinkElement = document.createElement('a');
secondLinkElement.href = secondMovieUrl;
secondLinkElement.target = '_blank';
secondLinkElement.textContent = "Generated URL 2: " + secondMovieUrl;
movieResultElement.appendChild(firstLinkElement);
movieResultElement.appendChild(firstIframe);
movieResultElement.appendChild(document.createElement('br')); // Add a line break
movieResultElement.appendChild(secondLinkElement);
movieResultElement.appendChild(secondIframe);
movieCopyButton.disabled = false;
window.generatedFirstMovieUrl = firstMovieUrl;
window.generatedSecondMovieUrl = secondMovieUrl;
} else {
movieResultElement.innerHTML = 'Movie not found';
movieCopyButton.disabled = true;
}
})
.catch(error => {
console.error('Error fetching movie data:', error);
document.getElementById('movieResult').innerHTML = 'Error fetching movie data';
document.getElementById('movieCopyButton').disabled = true;
});
}
function copyMovieToClipboard() {
const generatedMovieUrl = window.generatedMovieUrl;
if (!generatedMovieUrl) {
console.error('No generated movie URL to copy.');
return;
}
const textarea = document.createElement('textarea');
textarea.value = generatedMovieUrl;
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand('copy');
console.log('URL copied to clipboard:', generatedMovieUrl);
} catch (error) {
console.error('Error copying to clipboard:', error);
} finally {
document.body.removeChild(textarea);
}
}
function clearMovieSuggestions() {
document.getElementById('movieSuggestions').innerHTML = '';
}
function getSeriesSuggestions() {
const seriesName = document.getElementById('seriesName').value;
const apiKey = '69a6237ce6938d2fb74092f8ff3a8f16'; // Replace with your TMDb API key
if (seriesName.trim() === '') {
clearSeriesSuggestions();
return;
}
fetch(`https://api.themoviedb.org/3/search/tv?api_key=${apiKey}&query=${encodeURIComponent(seriesName)}`)
.then(response => response.json())
.then(data => {
const seriesSuggestionsList = document.getElementById('seriesSuggestions');
seriesSuggestionsList.innerHTML = '';
if (data.results && data.results.length > 0) {
data.results.slice(0, 5).forEach(result => {
const listItem = document.createElement('li');
listItem.textContent = result.name;
listItem.onclick = function () {
document.getElementById('seriesName').value = result.name;
clearSeriesSuggestions();
};
seriesSuggestionsList.appendChild(listItem);
});
}
})
.catch(error => {
console.error('Error fetching series suggestions:', error);
clearSeriesSuggestions();
});
}
function searchSeries() {
const seriesName = document.getElementById('seriesName').value;
const apiKey = '69a6237ce6938d2fb74092f8ff3a8f16'; // Replace with your TMDb API key
fetch(`https://api.themoviedb.org/3/search/tv?api_key=${apiKey}&query=${encodeURIComponent(seriesName)}`)
.then(response => response.json())
.then(data => {
const seriesResultElement = document.getElementById('seriesResult');
const seriesCopyButton = document.getElementById('seriesCopyButton');
if (data.results && data.results.length > 0) {
const seriesTmdbId = data.results[0].id;
const firstSeriesUrl = `https://vidsrc.xyz/embed/tv/${seriesTmdbId}`;
const secondSeriesUrl = `https://vidsrc.to/embed/tv/${seriesTmdbId}`;
const firstIframe = document.createElement('iframe');
firstIframe.src = firstSeriesUrl;
firstIframe.allowfullscreen = true;
const secondIframe = document.createElement('iframe');
secondIframe.src = secondSeriesUrl;
secondIframe.allowfullscreen = true;
seriesResultElement.innerHTML = '';
const firstLinkElement = document.createElement('a');
firstLinkElement.href = firstSeriesUrl;
firstLinkElement.target = '_blank';
firstLinkElement.textContent = 'Generated URL 1: ' + firstSeriesUrl;
const secondLinkElement = document.createElement('a');
secondLinkElement.href = secondSeriesUrl;
secondLinkElement.target = '_blank';
secondLinkElement.textContent = 'Generated URL 2: ' + secondSeriesUrl;
seriesResultElement.appendChild(firstLinkElement);
seriesResultElement.appendChild(firstIframe);
seriesResultElement.appendChild(document.createElement('br')); // Add a line break
seriesResultElement.appendChild(secondLinkElement);
seriesResultElement.appendChild(secondIframe);
seriesCopyButton.disabled = false;
window.generatedFirstSeriesUrl = firstSeriesUrl;
window.generatedSecondSeriesUrl = secondSeriesUrl;
} else {
seriesResultElement.innerHTML = 'Series not found';
seriesCopyButton.disabled = true;
}
})
.catch(error => {
console.error('Error fetching series data:', error);
document.getElementById('seriesResult').innerHTML = 'Error fetching series data';
// Disable the copy button for the series in case of an error
document.getElementById('seriesCopyButton').disabled = true;
});
}
function copySeriesToClipboard() {
const generatedSeriesUrl = window.generatedSeriesUrl;
if (!generatedSeriesUrl) {
console.error('No generated series URL to copy.');
return;
}
// Create a temporary textarea element
const textarea = document.createElement('textarea');
textarea.value = generatedSeriesUrl;
// Append it to the body
document.body.appendChild(textarea);
// Select the text
textarea.select();
try {
// Use the Clipboard API to copy the text to the clipboard
document.execCommand('copy');
console.log('URL copied to clipboard:', generatedSeriesUrl);
} catch (error) {
console.error('Error copying to clipboard:', error);
} finally {
// Remove the temporary textarea
document.body.removeChild(textarea);
}
}
function clearSeriesSuggestions() {
document.getElementById('seriesSuggestions').innerHTML = '';
}
const API_KEY = '69a6237ce6938d2fb74092f8ff3a8f16';
async function searchMovie() {
const movieName = document.getElementById('movieName').value;
const movieIdInput = document.getElementById('movieId');
const resultDisplay = document.getElementById('resultDisplay');
const searchUrl = `https://api.themoviedb.org/3/search/movie?query=${encodeURIComponent(movieName)}&api_key=${API_KEY}`;
try {
const response = await fetch(searchUrl);
const searchResults = await response.json();
if (searchResults.results && searchResults.results.length > 0) {
const firstMovie = searchResults.results[0];
const movieId = firstMovie.id;
const movieTitle = firstMovie.title;
movieIdInput.value = movieId;
resultDisplay.textContent = `Movie found: ${movieTitle} (ID: ${movieId})`;
} else {
resultDisplay.textContent = `No results found for '${movieName}'`;
}
} catch (error) {
console.error('Error fetching movie data:', error);
}
}