Remove API
This commit is contained in:
parent
04f0fd88eb
commit
59067bf415
|
@ -3,7 +3,6 @@ Mastodon.py
|
||||||
Pillow
|
Pillow
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
httpx
|
httpx
|
||||||
django-tastypie
|
|
||||||
django-admin-list-filter-dropdown
|
django-admin-list-filter-dropdown
|
||||||
wikipedia-api
|
wikipedia-api
|
||||||
bs4
|
bs4
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
from tastypie import fields
|
|
||||||
from tastypie.authentication import Authentication
|
|
||||||
from tastypie.resources import ModelResource
|
|
||||||
from tastypie.throttle import BaseThrottle
|
|
||||||
from tastypie.constants import ALL, ALL_WITH_RELATIONS
|
|
||||||
|
|
||||||
from main.models import Movie
|
|
||||||
from main.models import Person
|
|
||||||
from main.models import Country
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
|
|
||||||
class CustomAuthentication(Authentication):
|
|
||||||
def is_authenticated(self, request, **kwargs):
|
|
||||||
if not "ApiToken" in request.headers:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if request.headers["ApiToken"] != settings.API_TOKEN:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceDirectors(ModelResource):
|
|
||||||
class Meta:
|
|
||||||
queryset = Person.objects.all().filter(is_director=True)
|
|
||||||
resource_name = "directors"
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceCountries(ModelResource):
|
|
||||||
class Meta:
|
|
||||||
queryset = Country.objects.all()
|
|
||||||
resource_name = "countries"
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceMovies(ModelResource):
|
|
||||||
directors = fields.ToManyField(ResourceDirectors, "directors", full=True)
|
|
||||||
countries = fields.ToManyField(ResourceCountries, "countries", full=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
queryset = Movie.objects.all().order_by("-id")
|
|
||||||
resource_name = "movies"
|
|
||||||
excludes = ["count", "duration", "published", "stars"]
|
|
||||||
throttle = BaseThrottle(throttle_at=50)
|
|
||||||
allowed_methods = ["get"]
|
|
||||||
authentication = CustomAuthentication()
|
|
||||||
limit = 10
|
|
||||||
max_limit = 10
|
|
||||||
filtering = {
|
|
||||||
"name": ALL,
|
|
||||||
"original_name": ALL,
|
|
||||||
}
|
|
||||||
|
|
||||||
def dehydrate_directors(self, bundle):
|
|
||||||
names = ", ".join([d.obj.name for d in bundle.data["directors"]])
|
|
||||||
return names
|
|
||||||
|
|
||||||
def dehydrate_countries(self, bundle):
|
|
||||||
names = ", ".join([c.obj.name for c in bundle.data["countries"]])
|
|
||||||
return names
|
|
||||||
|
|
||||||
# ~ def build_filters(self, filters=None, **kwargs):
|
|
||||||
# ~ orm_filters = super().build_filters(filters or {}, **kwargs)
|
|
||||||
# ~ return orm_filters
|
|
||||||
|
|
||||||
def apply_filters(self, request, applicable_filters):
|
|
||||||
objects = self.get_object_list(request)
|
|
||||||
query = applicable_filters["name__icontains"]
|
|
||||||
qset = Q(name__icontains=query) | Q(original_name__icontains=query)
|
|
||||||
objects = objects.filter(qset)
|
|
||||||
return objects
|
|
|
@ -123,7 +123,7 @@ class MovieQuerySet(models.QuerySet):
|
||||||
"""
|
"""
|
||||||
Regresa la selección de películas para el 'home'.
|
Regresa la selección de películas para el 'home'.
|
||||||
|
|
||||||
El 'home' es la página principal.
|
El 'home' es la página principal.
|
||||||
"""
|
"""
|
||||||
genders = list(Gender.objects.values_list("id", flat=True))
|
genders = list(Gender.objects.values_list("id", flat=True))
|
||||||
sections = self.home_sections()
|
sections = self.home_sections()
|
||||||
|
@ -167,7 +167,7 @@ class MovieQuerySet(models.QuerySet):
|
||||||
movie["count_formatted"] = self.format_count(movie["count"])
|
movie["count_formatted"] = self.format_count(movie["count"])
|
||||||
movie["stars_icons"] = self.format_stars(movie["stars"])
|
movie["stars_icons"] = self.format_stars(movie["stars"])
|
||||||
movie["file_name"] = self.fix_path(movie["file_name"])
|
movie["file_name"] = self.fix_path(movie["file_name"])
|
||||||
movie["cartel"] = self.fix_path(movie["cartel"])
|
movie["cartel"] = settings.MEDIA_URL + movie["cartel"]
|
||||||
if wikipedia:
|
if wikipedia:
|
||||||
movie["wiki"] = self.get_wiki(movie)
|
movie["wiki"] = self.get_wiki(movie)
|
||||||
|
|
||||||
|
@ -178,6 +178,7 @@ class MovieQuerySet(models.QuerySet):
|
||||||
La ruta es distinta según se esté en producción o en desarrollo
|
La ruta es distinta según se esté en producción o en desarrollo
|
||||||
('DEBUG').
|
('DEBUG').
|
||||||
"""
|
"""
|
||||||
|
# ~ print('EL', el)
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
return settings.URL_DEBUG.format(el)
|
return settings.URL_DEBUG.format(el)
|
||||||
else:
|
else:
|
||||||
|
@ -287,7 +288,7 @@ class MovieQuerySet(models.QuerySet):
|
||||||
|
|
||||||
def get_movie_selector(self, prefix):
|
def get_movie_selector(self, prefix):
|
||||||
"""
|
"""
|
||||||
Obtiene el selector para filtrar la consulta de una búsqueda.
|
Obtiene el selector para filtrar la consulta de una búsqueda.
|
||||||
|
|
||||||
Esto permite restricciones en la búsqueda con esta sintaxis:
|
Esto permite restricciones en la búsqueda con esta sintaxis:
|
||||||
* t:Un Título => Buscará las películas que tengan 'Un T…' en sus 'name'
|
* t:Un Título => Buscará las películas que tengan 'Un T…' en sus 'name'
|
||||||
|
|
|
@ -21,6 +21,7 @@ from .conf import (
|
||||||
TOKEN_TELEGRAM,
|
TOKEN_TELEGRAM,
|
||||||
CHAT_ID,
|
CHAT_ID,
|
||||||
API_TOKEN,
|
API_TOKEN,
|
||||||
|
URL_DEBUG,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,6 +143,5 @@ DISALLOWED_USER_AGENTS = (
|
||||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||||
SESSION_COOKIE_AGE = 3600
|
SESSION_COOKIE_AGE = 3600
|
||||||
|
|
||||||
URL_DEBUG = "http://124.124.24.24/mauflix/{}"
|
|
||||||
URL_CDN = "https://mauflix.elmau.net/{}"
|
URL_CDN = "https://mauflix.elmau.net/{}"
|
||||||
URL_MASTODON = "https://mstdn.mx/"
|
URL_MASTODON = "https://mstdn.mx/"
|
||||||
|
|
|
@ -4,15 +4,15 @@ from django.conf import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.conf.urls import include
|
from django.conf.urls import include
|
||||||
|
|
||||||
from tastypie.api import Api
|
# ~ from tastypie.api import Api
|
||||||
|
|
||||||
from main import views
|
from main import views
|
||||||
from main.feeds import LatestMoviesFeed
|
from main.feeds import LatestMoviesFeed
|
||||||
from main.api import ResourceMovies
|
# ~ from main.api import ResourceMovies
|
||||||
|
|
||||||
|
|
||||||
v1_api = Api(api_name="v1")
|
# ~ v1_api = Api(api_name="v1")
|
||||||
v1_api.register(ResourceMovies())
|
# ~ v1_api.register(ResourceMovies())
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<b>TODO: Acerca</b>
|
<h1>Acerca de MauFlix</h1>
|
||||||
|
<br><br>
|
||||||
|
<p>
|
||||||
|
MauFlix es una videoteca personal. La misma no persigue ningún tipo de lucro y solo cuenta con datos informativos de las películas no con enlaces de descarga.
|
||||||
|
</p>
|
||||||
|
<br>
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p><b>BCH</b>: <code>qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d</code></p>
|
<p><b>G1</b>: <code>GwhvskhBj6B6JYQLo3E9S97PFfL6gw3LgmYG1cTsjQkF</code></p>
|
||||||
<p><b>BTC</b>: <code>3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV</code></p>
|
|
||||||
<p><b>LTC</b>: <code>MBcgQ3LQJA4W2wsXknTdm2fxRSysLaBJHS</code></p>
|
|
||||||
<p><b>ETH</b>: <code>0x61a4f614a30ff686445751ed8328b82b77ecfc69</code></p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="content has-text-centered">
|
<div class="content has-text-centered">
|
||||||
<p>Te recomendamos <a href="https://www.videolan.org/vlc/" target="_blank">VLC</a> para ver tus películas.</p>
|
<p>Te recomendamos <a href="https://www.videolan.org/vlc/" target="_blank">VLC</a> para ver tus películas.</p>
|
||||||
|
|
Loading…
Reference in New Issue