260701_010012
This commit is contained in:
parent
454793ce24
commit
69aab6345c
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,19 +0,0 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/web
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=web
|
||||
|
||||
### Web ###
|
||||
*.asp
|
||||
*.cer
|
||||
*.csr
|
||||
*.css
|
||||
*.htm
|
||||
*.html
|
||||
*.js
|
||||
*.jsp
|
||||
*.php
|
||||
*.rss
|
||||
*.wasm
|
||||
*.wat
|
||||
*.xhtml
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/web
|
||||
25
website/index.html
Normal file
25
website/index.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>moira_db</title>
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.png"/>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="styles.css">
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<input type="text" id="inEl">
|
||||
|
||||
<div>
|
||||
<h1 id="filmInfo_title"></h1>
|
||||
<h3 id="filmInfo_year"></h3></br>
|
||||
<p id="filmInfo_desc"></p></br>
|
||||
<img id="filmInfo_img" width="300" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
76
website/script.js
Normal file
76
website/script.js
Normal file
@ -0,0 +1,76 @@
|
||||
window.onload = () => {
|
||||
var fetch_filmInfo = async (in_url)=>{
|
||||
// pretty good test redirect: https://share.google/mSDJehdZm6hp6vTYy
|
||||
var resp;
|
||||
|
||||
|
||||
//resp = await fetch("https://www.imdb.com/title/tt0245429/?ref_=nv_sr_srsg_0_tt_8_nm_0_in_0_q_spirited");
|
||||
//resp = await fetch("https://www.filmweb.pl/film/Spirited+Away%3A+W+krainie+Bog%C3%B3w-2001-33288");
|
||||
resp = await fetch(in_url);
|
||||
//console.log("Redirected:", response.redirected);
|
||||
console.log("Redirected URL:", resp.url);
|
||||
noRed_URL = resp.url;
|
||||
|
||||
|
||||
var api_URL = null;
|
||||
noRed_URL = new URL(noRed_URL);
|
||||
const db_host = noRed_URL.hostname;
|
||||
noRed_URL.search = '';
|
||||
|
||||
switch(db_host){
|
||||
case "www.filmweb.pl":
|
||||
api_URL = `https://www.filmweb.pl/api/v1/film/${noRed_URL.href.slice(noRed_URL.href.lastIndexOf("-")+1)}/preview`;
|
||||
break;
|
||||
|
||||
case "www.imdb.com":
|
||||
// https://imdbapi.dev/
|
||||
noRed_URL.hostname = "api.imdbapi.dev";
|
||||
api_URL = noRed_URL.href.replace("/title/", "/titles/").slice(0, -1);
|
||||
break;
|
||||
}
|
||||
console.log("API URL:", api_URL);
|
||||
|
||||
|
||||
var resp = await fetch(api_URL)
|
||||
var data = await resp.json();
|
||||
console.log("Ext info:", data);
|
||||
|
||||
|
||||
var film_info = null;
|
||||
|
||||
switch(db_host){
|
||||
case "www.filmweb.pl":
|
||||
film_info = {};
|
||||
film_info["title_en"] = data["internationalTitle"] ? data["internationalTitle"]["title"] : data["originalTitle"]["title"];
|
||||
film_info["title_pl"] = data["title"]["title"];
|
||||
film_info["desc"] = data["plotOrDescriptionSynopsis"];
|
||||
film_info["year"] = data["year"];
|
||||
//film_info["img"] = data["coverPhoto"]["photo"]["sourcePath"];
|
||||
film_info["img"] = "https://fwcdn.pl/fpo"+data["poster"]["path"];
|
||||
//directors
|
||||
//countries
|
||||
//poster
|
||||
break;
|
||||
|
||||
case "www.imdb.com":
|
||||
film_info = {};
|
||||
film_info["title_en"] = data["primaryTitle"];
|
||||
film_info["title_pl"] = null;
|
||||
film_info["desc"] = data["plot"];
|
||||
film_info["year"] = data["startYear"];
|
||||
film_info["img"] = data["primaryImage"]["url"];
|
||||
break;
|
||||
}
|
||||
console.log("Film info:", film_info);
|
||||
|
||||
|
||||
document.getElementById("filmInfo_title").innerHTML = film_info["title_pl"] ? film_info["title_pl"] : film_info["title_en"];
|
||||
document.getElementById("filmInfo_year").innerHTML = film_info["year"];
|
||||
document.getElementById("filmInfo_desc").innerHTML = film_info["desc"];
|
||||
document.getElementById("filmInfo_img").src = film_info["img"];
|
||||
};
|
||||
|
||||
document.getElementById("inEl").addEventListener("input", function(){
|
||||
fetch_filmInfo(this.value);
|
||||
});
|
||||
};
|
||||
4
website/styles.css
Normal file
4
website/styles.css
Normal file
@ -0,0 +1,4 @@
|
||||
body{
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user