Commit 2dfe7dd4 authored by echel0n's avatar echel0n
Browse files

Bumped babelfish requirement

Added import exception handling for collections Iterable import for backwards-compatibility
Replaced AttrDict with CleverDict
Fixed `NoneType` issue with rating/votes for imdb popular shows
Fixed issue with bad comparison of NoneTypes for config.ini migration code
Fixed issue with NMA priority being string value when db column is int
parent edf164b7
......@@ -7,7 +7,7 @@ APScheduler==3.6.3
arrow==0.15.8
asn1crypto==1.4.0
attrs==19.3.0
babelfish==0.5.5
babelfish==0.6.0
beautifulsoup4==4.10.0
bencode3==0.1.0
bleach==3.3.0
......@@ -15,6 +15,7 @@ CacheControl==0.12.6
certifi==2021.5.30
cffi==1.14.1
chardet==3.0.4
cleverdict==1.9.2
click==7.1.2
cloudscraper==1.2.46
configobj==5.0.6
......
This diff is collapsed.
......@@ -1218,7 +1218,7 @@ class Config(object):
self.nma.notify_on_subtitle_download = self._get_config_file_value(config_object, 'NMA', 'nma_notify_onsubtitledownload',
default=self.nma.notify_on_subtitle_download, field_type=bool)
self.nma.api_keys = self._get_config_file_value(config_object, 'NMA', 'nma_api', default=self.nma.api_keys, field_type=str)
self.nma.priority = self._get_config_file_value(config_object, 'NMA', 'nma_priority', default=self.nma.priority, field_type=str)
self.nma.priority = self._get_config_file_value(config_object, 'NMA', 'nma_priority', default=self.nma.priority, field_type=int)
# PUSHALOT SETTINGS
self.pushalot.enable = self._get_config_file_value(config_object, 'Pushalot', 'use_pushalot', default=self.pushalot.enable, field_type=bool)
......@@ -1416,7 +1416,7 @@ class Config(object):
if not field_type:
field_type = str
if not default:
if default is None:
default = field_type() if field_type is not str.upper else str()
if section in config_object:
......@@ -1424,7 +1424,7 @@ class Config(object):
if key in section_object:
try:
value = self.convert_value(section_object.get(key), field_type)
if not value:
if value is None:
return default
return value
except Exception:
......
......@@ -29,6 +29,7 @@ import alembic.script
import sqlalchemy
from alembic.runtime.migration import MigrationContext
from alembic.script import ScriptDirectory
from cleverdict import CleverDict
from sqlalchemy import create_engine, event, inspect, MetaData, Index, TypeDecorator
from sqlalchemy.engine import Engine, reflection, Row
from sqlalchemy.exc import OperationalError
......@@ -125,16 +126,7 @@ class SRDatabaseBase(object):
return {c.key: getattr(self, c.key) for c in inspect(self).mapper.column_attrs}
def as_attrdict(self):
class AttrDict:
def __init__(self, in_dict: dict):
assert isinstance(in_dict, dict)
for key, val in in_dict.items():
if isinstance(val, (list, tuple)):
setattr(self, key, [AttrDict(x) if isinstance(x, dict) else x for x in val])
else:
setattr(self, key, AttrDict(val) if isinstance(val, dict) else val)
return AttrDict(self.as_dict())
return CleverDict(self.as_dict())
def update(self, **kwargs):
primary_keys = [pk.name for pk in self.__table__.primary_key]
......
"""Initial migration
Revision ID: 7
Revises:
Create Date: 2017-12-29 14:39:27.854291
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '7'
down_revision = '6'
def upgrade():
conn = op.get_bind()
meta = sa.MetaData(bind=conn)
nma = sa.Table('nma', meta, autoload=True)
for row in conn.execute(nma.select()):
priority = row.priority
if isinstance(priority, str):
try:
priority = int(priority or 0)
except ValueError:
priority = 0
conn.execute(f'UPDATE nma SET priority = {priority} WHERE nma.id = {row.id}')
def downgrade():
pass
......@@ -42,10 +42,17 @@ import unicodedata
import uuid
import webbrowser
import zipfile
from collections import OrderedDict, Iterable
from collections import OrderedDict
from contextlib import contextmanager
from urllib.parse import uses_netloc, urlsplit, urlunsplit, urljoin
try:
# Python <= 3.9
from collections import Iterable
except ImportError:
# Python > 3.9
from collections.abc import Iterable
import errno
import rarfile
import requests
......
......@@ -51,13 +51,8 @@
% else:
% for cur_result in popular_shows:
% if not cur_result['imdb_tt'] in imdb_tt:
% if 'rating' in cur_result and cur_result['rating']:
<% cur_rating = cur_result['rating'] %>
<% cur_votes = cur_result['votes'] %>
% else:
<% cur_rating = '0' %>
<% cur_votes = '0' %>
% endif
<% cur_rating = cur_result.get('rating') or '0' %>
<% cur_votes = cur_result.get('votes') or '0' %>
<div class="show-container" data-name="${cur_result['name']}"
data-rating="${cur_rating}"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment