Fix #8
This commit is contained in:
parent
ed24e0ea77
commit
0046f9da8d
|
@ -1,6 +1,8 @@
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import wikipediaapi
|
import wikipediaapi
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -170,12 +172,12 @@ class MovieQuerySet(models.QuerySet):
|
||||||
movie["duration_formatted"] = self.format_duration(movie["duration"])
|
movie["duration_formatted"] = self.format_duration(movie["duration"])
|
||||||
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(movie["file_name"])
|
||||||
movie["cartel"] = f"{settings.MEDIA_URL}{movie['cartel']}"
|
movie["cartel"] = self._fix_path_cartel(movie['cartel'])
|
||||||
if wikipedia:
|
if wikipedia:
|
||||||
movie["wiki"] = self.get_wiki(movie)
|
movie["wiki"] = self.get_wiki(movie)
|
||||||
|
|
||||||
def fix_path(self, file_name):
|
def _fix_path_movie(self, file_name):
|
||||||
"""
|
"""
|
||||||
Enmienda ruta a medio.
|
Enmienda ruta a medio.
|
||||||
"""
|
"""
|
||||||
|
@ -188,6 +190,17 @@ class MovieQuerySet(models.QuerySet):
|
||||||
url = f"{settings.URL_CDN}/{letter}/{file_name}"
|
url = f"{settings.URL_CDN}/{letter}/{file_name}"
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def _fix_path_cartel(self, file_name):
|
||||||
|
""" Si no existe el cartel regresa el default """
|
||||||
|
url = f"{settings.MEDIA_URL}{file_name}"
|
||||||
|
|
||||||
|
path = Path(f"{settings.MEDIA_ROOT}{file_name}")
|
||||||
|
if not path.exists():
|
||||||
|
url = f"{settings.MEDIA_URL}default.png"
|
||||||
|
|
||||||
|
return url
|
||||||
|
|
||||||
|
|
||||||
def fix_summ(self, raw):
|
def fix_summ(self, raw):
|
||||||
"""
|
"""
|
||||||
Enmienda sinopsis de Wikipedia.
|
Enmienda sinopsis de Wikipedia.
|
||||||
|
|
Loading…
Reference in New Issue