feat [both]: tmdb calls from django
This commit is contained in:
parent
fe717f94f1
commit
b40916c7f4
6 changed files with 39 additions and 11 deletions
|
@ -132,7 +132,7 @@
|
||||||
<!-- doc : https://bluefantail.github.io/bulma-list/ -->
|
<!-- doc : https://bluefantail.github.io/bulma-list/ -->
|
||||||
<div class="list has-visible-pointer-controls">
|
<div class="list has-visible-pointer-controls">
|
||||||
<div
|
<div
|
||||||
v-for="(foundFilm, index) of foundFilms?.results"
|
v-for="(foundFilm, index) of foundFilms"
|
||||||
:key="foundFilm.id"
|
:key="foundFilm.id"
|
||||||
class="list-item"
|
class="list-item"
|
||||||
>
|
>
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
<div class="list-item-content">
|
<div class="list-item-content">
|
||||||
<div class="list-item-title">{{ foundFilm.title }}</div>
|
<div class="list-item-title">{{ foundFilm.title }}</div>
|
||||||
<div class="list-item-description">
|
<div class="list-item-description">
|
||||||
{{ foundFilm.release_date }}
|
{{ foundFilm.releaseDate }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="list-item-controls">
|
<div class="list-item-controls">
|
||||||
|
@ -176,7 +176,7 @@ const film = useModel<Film>("modelValue", { type: "object" })
|
||||||
const foundFilms = ref()
|
const foundFilms = ref()
|
||||||
// https://developers.themoviedb.org/3/getting-started/images
|
// https://developers.themoviedb.org/3/getting-started/images
|
||||||
const image = computed(() => (index: number) => {
|
const image = computed(() => (index: number) => {
|
||||||
return `https://image.tmdb.org/t/p/w500${foundFilms.value?.results[index].poster_path}`
|
return `https://image.tmdb.org/t/p/w500${foundFilms.value[index]?.posterPath}`
|
||||||
})
|
})
|
||||||
|
|
||||||
const durationNoSecond = computed<string>({
|
const durationNoSecond = computed<string>({
|
||||||
|
@ -187,12 +187,8 @@ const durationNoSecond = computed<string>({
|
||||||
})
|
})
|
||||||
|
|
||||||
async function findFilm() {
|
async function findFilm() {
|
||||||
foundFilms.value = await $fetch("https://api.themoviedb.org/3/search/movie", {
|
foundFilms.value = (
|
||||||
params: {
|
await apiGet("tmdb/search/", { query: film.value.title })
|
||||||
api_key: "INSERT API KEY HERE",
|
).data.value
|
||||||
language: "fr-FR",
|
|
||||||
query: title.value,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
from .views.std_views import FilmViewSet
|
from .views.std_views import FilmViewSet
|
||||||
|
from .views.tmdb_views import TmdbViewSet
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r"films", FilmViewSet)
|
router.register(r"films", FilmViewSet)
|
||||||
|
router.register(r"tmdb", TmdbViewSet, "tmdb")
|
||||||
|
|
||||||
# Wire up our API using automatic URL routing.
|
# Wire up our API using automatic URL routing.
|
||||||
# Additionally, we include login URLs for the browsable API.
|
# Additionally, we include login URLs for the browsable API.
|
||||||
|
|
0
server/myapi/views/__init__.py
Normal file
0
server/myapi/views/__init__.py
Normal file
26
server/myapi/views/tmdb_views.py
Normal file
26
server/myapi/views/tmdb_views.py
Normal file
File diff suppressed because one or more lines are too long
|
@ -3,3 +3,4 @@ djangorestframework==3.13.1
|
||||||
django-cors-headers==3.11.0
|
django-cors-headers==3.11.0
|
||||||
djangorestframework-camel-case==1.3.0
|
djangorestframework-camel-case==1.3.0
|
||||||
getconf~=1.11.1
|
getconf~=1.11.1
|
||||||
|
tmdbv3api~=1.7.6
|
||||||
|
|
|
@ -16,4 +16,7 @@ Including another URLconf
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [path("admin/", admin.site.urls), path("api/", include("myapi.urls"))]
|
urlpatterns = [
|
||||||
|
path("admin/", admin.site.urls),
|
||||||
|
path("api/", include("myapi.urls")),
|
||||||
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue