-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
188 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Nahieran-JS</title> | ||
<link rel="stylesheet" href="./style.css"> | ||
<!-- CSS only --> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> | ||
<!-- JavaScript Bundle with Popper --> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" | ||
crossorigin="anonymous"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>NahieranJS</h1> | ||
<section> | ||
<h2>Get TV Categories</h2> | ||
<code lang="javascript">import { getTVCategories } from "nahieran-js"; | ||
getTVCategories().then(res => { | ||
console.log("Response: ", res); | ||
}, err => { | ||
console.error("Response error: ", err); | ||
}); | ||
</code> | ||
|
||
<br> | ||
DEMO: <button type="button" class="btn btn-primary" onclick="getDocTVCategories()">Get TV | ||
Categories</button> | ||
</section> | ||
|
||
|
||
|
||
<section> | ||
<h2>Get TV Category</h2> | ||
|
||
<br> | ||
DEMO: <button type="button" class="btn btn-primary" onclick="getDocTVCategory('PELICULAS')">Get TV Category</button> | ||
</section> | ||
</div> | ||
|
||
|
||
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" | ||
aria-hidden="true"> | ||
<div class="modal-dialog modal-xl"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="modalTitle">...</h5> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body" id="modalBody"> | ||
... | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
|
||
<script type="module"> | ||
import { getTVCategories, getTVCategory } from "../src/index.js"; | ||
const myModal = new bootstrap.Modal(document.getElementById("exampleModal"), {}); | ||
const getDocTVCategories = () => { | ||
getTVCategories().then(res => { | ||
console.log("Response: ", res); | ||
document.getElementById("modalTitle").innerText = "Get TV Categories"; | ||
document.getElementById("modalBody").innerText = JSON.stringify(res); | ||
myModal.show(); | ||
}, err => console.error("Response error: ", err)); | ||
}; | ||
|
||
const getDocTVCategory = (category_slug) => { | ||
getTVCategory(category_slug).then(res => { | ||
console.log("Response: ", res); | ||
document.getElementById("modalTitle").innerText = "Get TV Categories"; | ||
document.getElementById("modalBody").innerText = JSON.stringify(res); | ||
myModal.show(); | ||
}, err => console.error("Response error: ", err)); | ||
}; | ||
window.getDocTVCategories = getDocTVCategories; | ||
window.getDocTVCategory = getDocTVCategory; | ||
|
||
</script> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
code { | ||
font-family: Consolas,"courier new"; | ||
color: crimson; | ||
background-color: #f1f1f1; | ||
padding: 2px; | ||
font-size: 105%; | ||
/* white-space: pre-wrap */ | ||
white-space: pre-line | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const TV_DOMAIN_PATH = "https://mam.eitb.eus" | ||
|
||
export const TV_API_PATH = `${TV_DOMAIN_PATH}/mam/REST/ServiceMultiweb`; | ||
|
||
export const TV_API_CATEGORIES = '/WebClasif/MULTIWEBTV/8/1/0/'; | ||
export const TV_API_CATEGORY = '/Grouplist/Clasification/MULTIWEBTV/8'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import { TV_API_PATH } from "../contants.js"; | ||
|
||
const fetchAPI = (param) => { | ||
return new Promise((resolve, reject) => { | ||
fetch(`${TV_API_PATH}${param}`) | ||
.then((response) => response.json()) | ||
.then((data) => resolve(data)).catch(err => reject(err)); | ||
}); | ||
|
||
}; | ||
|
||
export { fetchAPI }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { TV_API_CATEGORIES, TV_API_CATEGORY } from "./contants.js" | ||
import { fetchAPI } from "./helpers/fetch.js" | ||
|
||
const getTVCategories = () => { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
const data = await fetchAPI(TV_API_CATEGORIES); | ||
const parsedData = { | ||
count: data.num, | ||
timestamp: data.timestamp, | ||
categories: data.web_clasif.map(item => { | ||
return { | ||
id: item.ID_WEB_CLASIF, | ||
slug: item.CLASIFICACION, | ||
eu: item.CLASIFICACION_EU, | ||
es: item.CLASIFICACION_ES, | ||
fr: item.CLASIFICACION_FR, | ||
en: item.CLASIFICACION_EN | ||
} | ||
}) | ||
}; | ||
resolve(parsedData); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}) | ||
} | ||
|
||
const getTVCategory = (category_slug) => { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
const data = await fetchAPI(`${TV_API_CATEGORY}/${category_slug}/`); | ||
console.log("Get TV category: ", data) | ||
const parsedData = { | ||
count: data.num, | ||
timestamp: data.timestamp, | ||
program: data.web_group.map(item => { | ||
return { | ||
id: item.ID_WEB_GROUP, | ||
title: item.NOMBRE_GROUP, | ||
order: item.ORDEN, | ||
description: item.SHORT_DESC, | ||
images: item.images.map(image => { | ||
return { | ||
height: image.HEIGHT, | ||
width: image.WIDTH, | ||
order: image.ORDEN, | ||
url: data.vod_url + image.URL | ||
} | ||
}) | ||
} | ||
}) | ||
}; | ||
resolve(parsedData); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}) | ||
} | ||
|
||
// export default getTelesaiak; | ||
export { | ||
getTVCategories, | ||
getTVCategory | ||
} |
This file was deleted.
Oops, something went wrong.