use requests

This commit is contained in:
j 2019-06-28 12:49:08 +02:00
parent 893abbe9d5
commit ef633b00b1

View file

@ -7,6 +7,7 @@ import socket
import urllib
from django.db import models
import requests
import ox
import ox.web.criterion
@ -85,7 +86,7 @@ class PosterCache(models.Model):
url = self.url.encode('utf-8')
name = hashlib.sha1(url).hexdigest()
try:
data = ox.net.read_url(url)
data = requests.get(url, headers=ox.net.DEFAULT_HEADERS).content
self.image.name = poster_path(self.url, os.path.basename(self.url))
ox.makedirs(os.path.dirname(self.image.path))
with open(self.image.path, 'wb') as f: