diff --git a/books/templates/books/detail.html b/books/templates/books/detail.html index d36a621b..1c0964c9 100644 --- a/books/templates/books/detail.html +++ b/books/templates/books/detail.html @@ -15,6 +15,7 @@ + {% if book.author %} {% endif %} diff --git a/common/scraper.py b/common/scraper.py index 919c9b3b..9963d6a6 100644 --- a/common/scraper.py +++ b/common/scraper.py @@ -1,5 +1,7 @@ import requests +import functools import random +import logging from lxml import html import re from boofilsic.settings import LUMINATI_USERNAME, LUMINATI_PASSWORD, DEBUG @@ -30,6 +32,25 @@ TIMEOUT = 10 # luminati account credentials PORT = 22225 +logger = logging.getLogger(__name__) + + +def log_url(func): + """ + Catch exceptions and log then pass the exceptions. + First postion argument of decorated function must be the url. + """ + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + return func(*args, **kwargs) + except Exception as e: + # log the url + logger.error(f"Scrape Failed URL: {args[0]}") + raise e + + return wrapper + def download_page(url, regex, headers): url = regex.findall(url) @@ -85,6 +106,7 @@ def download_image(url): return raw_img +@log_url def scrape_douban_book(url): regex = RE_DOUBAN_BOOK_URL headers = DEFAULT_REQUEST_HEADERS.copy() @@ -214,6 +236,7 @@ def scrape_douban_book(url): return data, raw_img +@log_url def scrape_douban_movie(url): regex = RE_DOUBAN_MOVIE_URL headers = DEFAULT_REQUEST_HEADERS.copy() diff --git a/common/static/css/boofilsic.css b/common/static/css/boofilsic.css index 57a55f6d..7f2adce2 100644 --- a/common/static/css/boofilsic.css +++ b/common/static/css/boofilsic.css @@ -2180,3 +2180,7 @@ select::placeholder { .ms-parent > .ms-drop > ul > li > label > span { margin-left: 10px; } + +.ms-parent > .ms-drop > ul > li > label > input { + width: unset; +} diff --git a/common/static/sass/_Vendor.sass b/common/static/sass/_Vendor.sass index bc0af71a..6f765dfd 100644 --- a/common/static/sass/_Vendor.sass +++ b/common/static/sass/_Vendor.sass @@ -32,5 +32,9 @@ &:hover, &:focus color: black -.ms-parent > .ms-drop > ul > li > label > span - margin-left: 10px \ No newline at end of file +.ms-parent > .ms-drop > ul > li > label + & > span + margin-left: 10px + & > input + width: unset + diff --git a/common/templatetags/strip_protocol.py b/common/templatetags/strip_protocol.py new file mode 100644 index 00000000..67527d18 --- /dev/null +++ b/common/templatetags/strip_protocol.py @@ -0,0 +1,18 @@ +from django import template +from django.template.defaultfilters import stringfilter + +register = template.Library() + + +@register.filter(is_safe=True) +@stringfilter +def strip_protocol(value): + """ Strip the `https://.../` part of urls""" + if value.startswith("https://"): + value = value.replace("https://", '') + elif value.startswith("http://"): + value = value.replace("http://", '') + + if value.endswith('/'): + value = value[0:-1] + return value \ No newline at end of file diff --git a/movies/templates/movies/create_update_review.html b/movies/templates/movies/create_update_review.html index 593276b1..ec29fb3d 100644 --- a/movies/templates/movies/create_update_review.html +++ b/movies/templates/movies/create_update_review.html @@ -51,10 +51,24 @@ {% endif %}
{% if movie.director %}{% trans '导演:' %} - {% for director in movie.director %} - {{ director }}{% if not forloop.last %} / {% endif %} - {% endfor %} - {% endif %}
+ {% for director in movie.director %} + 5 %}style="display: none;" {% endif %}> + {{ director }} + {% if not forloop.last %} / {% endif %} + + {% endfor %} + {% if movie.director|length > 5 %} + {% trans '更多' %} + + {% endif %} + {% endif %}
{% if movie.genre %}{% trans '类型:' %} {% for genre in movie.get_genre_display %} {{ genre }}{% if not forloop.last %} / {% endif %} diff --git a/movies/templates/movies/detail.html b/movies/templates/movies/detail.html index e73d7994..df26ce85 100644 --- a/movies/templates/movies/detail.html +++ b/movies/templates/movies/detail.html @@ -6,6 +6,7 @@ {% load mastodon %} {% load oauth_token %} {% load truncate %} +{% load strip_protocol %} @@ -88,35 +89,61 @@
{% if movie.director %}{% trans '导演:' %} {% for director in movie.director %} - {{ director }}{% if not forloop.last %} / {% endif %} + 5 %}style="display: none;" {% endif %}> + {{ director }} + {% if not forloop.last %} / {% endif %} + {% endfor %} - {% endif %}
-
{% if movie.playwright %}{% trans '编剧:' %} - {% for playwright in movie.playwright %} - {{ playwright }}{% if not forloop.last %} / {% endif %} - {% endfor %} - {% endif %}
-
{% if movie.actor %}{% trans '主演:' %} - {% for actor in movie.actor %} - 5 %}style="display: none;"{% endif %}> - {{ actor }} - {% if not forloop.last %} / {% endif %} - - {% if forloop.counter <= 5 %} - {% endif %} - {% endfor %} - - {% if movie.actor|length > 5 %} - {% trans '更多' %} + {% if movie.director|length > 5 %} + {% trans '更多' %} - {% endif %} + {% endif %} + {% endif %}
+
{% if movie.playwright %}{% trans '编剧:' %} + {% for playwright in movie.playwright %} + 5 %}style="display: none;" {% endif %}> + {{ playwright }} + {% if not forloop.last %} / {% endif %} + + {% endfor %} + {% if movie.playwright|length > 5 %} + {% trans '更多' %} + + {% endif %} + {% endif %}
+
{% if movie.actor %}{% trans '主演:' %} + {% for actor in movie.actor %} + 5 %}style="display: none;"{% endif %}> + {{ actor }} + {% if not forloop.last %} / {% endif %} + + {% endfor %} + + {% if movie.actor|length > 5 %} + {% trans '更多' %} + + {% endif %} {% endif %}
{% if movie.genre %}{% trans '类型:' %} @@ -156,7 +183,7 @@ {% endfor %} {% endif %}
{% if movie.site %}{% trans '网站:' %} - {{ movie.site }} + {{ movie.site|strip_protocol }} {% endif %}
{% if movie.other_info %} {% for k, v in movie.other_info.items %} diff --git a/movies/templates/movies/mark_list.html b/movies/templates/movies/mark_list.html index 9598df78..9269414f 100644 --- a/movies/templates/movies/mark_list.html +++ b/movies/templates/movies/mark_list.html @@ -120,10 +120,24 @@
{% if movie.director %}{% trans '导演:' %} - {% for director in movie.director %} - {{ director }}{% if not forloop.last %} / {% endif %} - {% endfor %} - {% endif %}
+ {% for director in movie.director %} + 5 %}style="display: none;" {% endif %}> + {{ director }} + {% if not forloop.last %} / {% endif %} + + {% endfor %} + {% if movie.director|length > 5 %} + {% trans '更多' %} + + {% endif %} + {% endif %}
{% if movie.genre %}{% trans '类型:' %} {% for genre in movie.get_genre_display %} {{ genre }}{% if not forloop.last %} / {% endif %} diff --git a/movies/templates/movies/review_detail.html b/movies/templates/movies/review_detail.html index 28223bbe..85ea278b 100644 --- a/movies/templates/movies/review_detail.html +++ b/movies/templates/movies/review_detail.html @@ -99,10 +99,24 @@
{% if movie.director %}{% trans '导演:' %} - {% for director in movie.director %} - {{ director }}{% if not forloop.last %} / {% endif %} - {% endfor %} - {% endif %}
+ {% for director in movie.director %} + 5 %}style="display: none;" {% endif %}> + {{ director }} + {% if not forloop.last %} / {% endif %} + + {% endfor %} + {% if movie.director|length > 5 %} + {% trans '更多' %} + + {% endif %} + {% endif %}
{% if movie.genre %}{% trans '类型:' %} {% for genre in movie.get_genre_display %} {{ genre }}{% if not forloop.last %} / {% endif %} diff --git a/movies/templates/movies/review_list.html b/movies/templates/movies/review_list.html index 32ac2b76..83f6acfc 100644 --- a/movies/templates/movies/review_list.html +++ b/movies/templates/movies/review_list.html @@ -106,10 +106,24 @@
{% if movie.director %}{% trans '导演:' %} - {% for director in movie.director %} - {{ director }}{% if not forloop.last %} / {% endif %} - {% endfor %} - {% endif %}
+ {% for director in movie.director %} + 5 %}style="display: none;" {% endif %}> + {{ director }} + {% if not forloop.last %} / {% endif %} + + {% endfor %} + {% if movie.director|length > 5 %} + {% trans '更多' %} + + {% endif %} + {% endif %}
{% if movie.genre %}{% trans '类型:' %} {% for genre in movie.get_genre_display %} {{ genre }}{% if not forloop.last %} / {% endif %} diff --git a/users/templates/users/register.html b/users/templates/users/register.html index 1ffae6c2..2cb9d3ab 100644 --- a/users/templates/users/register.html +++ b/users/templates/users/register.html @@ -18,7 +18,7 @@
-

欢迎来到里瓣书影音(其实现在只有书)!

+

欢迎来到里瓣书影音(其实现在只有书汗电影)!

里瓣书影音继承了长毛象的用户关系,比如您在里瓣屏蔽了某人,那您将不会在书影音的公共区域看到TA的痕迹。 这里仍是一片处女地,丰富的内容需要大家共同创造! @@ -26,7 +26,7 @@ BTW欧盟惯例本站使用了Cookie,请理解!

- 此外里瓣书影音现处于“公开阿尔法测试”阶段,您的数据存在丢失的可能 + 此外里瓣书影音现处于“公开阿尔法测试”阶段,您的数据存在丢失的可能。

{% csrf_token %}