Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mass refactor tv.py #8706

Merged
merged 31 commits into from Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
83e529a
refactor: lowercase and typo function, parameter, and variable names …
miigotu Feb 3, 2024
a3055a7
fix: use property decorators instead of accessors to avoid type check…
miigotu Feb 3, 2024
e36b6fb
black
miigotu Feb 3, 2024
8a67418
chore: update release workflow
miigotu Feb 3, 2024
89546f4
refactor: missed changes
miigotu Feb 3, 2024
6989d8c
additional time error capture
BKSteve Feb 3, 2024
7ba09ac
refactor: more renaming and fixing types
miigotu Feb 3, 2024
0bcd73f
fix: can't add init to tornado base class? causes PageTemplate initia…
miigotu Feb 3, 2024
6850259
fix: try to fix airdate modify timestamp, remove some unneded mako co…
miigotu Feb 4, 2024
846aa4a
chore:black formatting
miigotu Feb 4, 2024
754e34f
air date tm_isdst
BKSteve Feb 4, 2024
c20da34
air date tm_isdst clean
BKSteve Feb 4, 2024
ae3e0ff
Merge branch 'develop' into wtf-is-wrong-with-me-lol
miigotu Feb 6, 2024
cb4c31b
backlog page variables - log reduction
BKSteve Feb 11, 2024
2a6deff
backlog page variables lowercase 2
BKSteve Feb 11, 2024
4735005
trending add - redirectable
BKSteve Feb 11, 2024
9614388
searchBacklog needs int
BKSteve Feb 11, 2024
0ac7c4c
subtitles remove legendastv
BKSteve Feb 11, 2024
7b58831
add shows redirect allowed
BKSteve Feb 12, 2024
18c4a7d
regex single char alternation - Qodana
BKSteve Feb 12, 2024
b44dc29
docstring parameters - Qodana
BKSteve Feb 12, 2024
6340a58
fstring logs
BKSteve Feb 12, 2024
212444f
fstring logs 2
BKSteve Feb 12, 2024
dacdd68
wordle
BKSteve Feb 12, 2024
140482a
remove show get*
BKSteve Feb 12, 2024
8e44069
snaking vars
BKSteve Feb 12, 2024
735ea0a
home unused var removal
BKSteve Feb 12, 2024
0fb6c6b
t.render layout
BKSteve Feb 12, 2024
bae210c
Failed download + params
BKSteve Feb 12, 2024
a6ed3a4
revert (_(f
BKSteve Feb 12, 2024
b96ea86
Merge branch 'develop' into wtf-is-wrong-with-me-lol
miigotu Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 1 addition & 9 deletions .editorconfig
@@ -1,15 +1,10 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
# and trailing whitespace removed
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{py,mako}]
charset = utf-8
indent_style = space
Expand All @@ -20,12 +15,9 @@ charset = utf-8
indent_style = space
indent_size = 4

# Matches configuration files for services like Travis, AppVeyor and Codecov
[*.yml]
indent_style = space
indent_size = 2

[{package.json, bower.json, webpack.config.js}]
charset = utf-8
indent_style = space
[{package.json,bower.json,webpack.config.js}]
indent_size = 2
miigotu marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Expand Up @@ -2,11 +2,9 @@ name: Build develop branch

on:
workflow_run:
workflows: [Python Packaging]
branches: |
- develop
types:
- completed
workflows: [ Python Packaging ]
branches: [ develop ]
types: [ completed, requested ]

jobs:
version:
Comment on lines 2 to 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [21-21]

Using cache: 'yarn' with actions/setup-node@v4 while running npm install -g yarn seems redundant. If Yarn is being used, consider removing the npm install -g yarn command or clarify the necessity of this approach.

Expand Down
11 changes: 6 additions & 5 deletions SickChill.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import datetime
import mimetypes
import os
import platform
import shutil
Expand Down Expand Up @@ -28,14 +29,12 @@

setup_gettext()

import mimetypes

mimetypes.add_type("text/css", ".css")
mimetypes.add_type("application/sfont", ".otf")
mimetypes.add_type("application/sfont", ".ttf")
mimetypes.add_type("application/javascript", ".js")
mimetypes.add_type("application/font-woff", ".woff")
# Not sure about this one, but we also have halflings in .woff so I think it wont matter
# Not sure about this one, but we also have halflings in .woff, so I think it won't matter
# mimetypes.add_type("application/font-woff2", ".woff2")

from configobj import ConfigObj
Expand Down Expand Up @@ -67,6 +66,8 @@ def __init__(self):
self.run_as_daemon = False

# web server constants
self.flask_server = None

self.web_server = None
self.forced_port = None
self.no_launch = False
Expand Down Expand Up @@ -253,7 +254,7 @@ def load_shows_from_db():
for sql_show in sql_results:
try:
cur_show = TVShow(sql_show["indexer"], sql_show["indexer_id"])
cur_show.nextEpisode()
cur_show.next_episode()
settings.showList.append(cur_show)
except Exception as error:
logger.exception("There was an error creating the show in {}: Error {}".format(sql_show["location"], error))
Expand Down Expand Up @@ -301,7 +302,7 @@ def shutdown(self, event):
"""
if settings.started:
sickchill.start.halt() # stop all tasks
sickchill.start.saveAll() # save all shows to DB
sickchill.start.save_all() # save all shows to DB

# shutdown web server
if self.web_server:
Expand Down
2 changes: 1 addition & 1 deletion sickchill/gui/slick/views/addShows_favoriteShows.mako
Expand Up @@ -96,7 +96,7 @@
<i>${cur_result.siteRatingCount}</i>
<div class="traktShowTitleIcons">
<a href="${scRoot}/addShows/addShowByID?indexer_id=${cur_result.id}&amp;show_name=${cur_result.seriesName | u}&amp;indexer=TVDB"
class="btn btn-xs" data-no-redirect>${_('Add Show')}</a>
class="btn btn-xs">${_('Add Show')}</a>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sickchill/gui/slick/views/addShows_popularShows.mako
Expand Up @@ -75,7 +75,7 @@

<div class="traktShowTitleIcons">
<a href="${scRoot}/addShows/addShowByID?indexer_id=${current_imdb_id}&amp;show_name=${current_result['title'] | u}&amp;indexer=IMDB"
class="btn btn-xs" data-no-redirect>${_('Add Show')}</a>
class="btn btn-xs">${_('Add Show')}</a>
</div>
</div>
</div>
Expand Down
68 changes: 34 additions & 34 deletions sickchill/gui/slick/views/config_providers.mako

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion sickchill/gui/slick/views/config_subtitles.mako
Expand Up @@ -326,7 +326,6 @@
<fieldset class="component-group-list">
<%
providerLoginDict = {
'legendastv': {'user': settings.LEGENDASTV_USER, 'pass': settings.LEGENDASTV_PASS},
'addic7ed': {'user': settings.ADDIC7ED_USER, 'pass': settings.ADDIC7ED_PASS},
'itasa': {'user': settings.ITASA_USER, 'pass': settings.ITASA_PASS},
'opensubtitles': {'user': settings.OPENSUBTITLES_USER, 'pass': settings.OPENSUBTITLES_PASS},
Expand Down
12 changes: 6 additions & 6 deletions sickchill/gui/slick/views/displayShow.mako
Expand Up @@ -404,9 +404,9 @@
(season_number, episode_number) = (default_season, default_episode)
default_episode_numbering = True

epLoc = epResult["location"]
if epLoc and show._location and epLoc.lower().startswith(show._location.lower()):
epLoc = epLoc[len(show._location)+1:]
episode_location = epResult["location"]
if episode_location and show.get_location and episode_location.lower().startswith(show.get_location.lower()):
episode_location = episode_location[len(show.get_location)+1:]
%>
% if int(epResult["season"]) != curSeason:
% if epResult["season"] != sql_results[0]["season"]:
Expand Down Expand Up @@ -485,8 +485,8 @@
<td class="text-center episode">
<%
text = str(epResult['episode'])
if epLoc:
text = '<span title="' + epLoc + '" class="addQTip">' + text + "</span>"
if episode_location:
text = '<span title="' + episode_location + '" class="addQTip">' + text + "</span>"
Comment on lines +488 to +489
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable episode_location is used within an HTML attribute without proper escaping, potentially leading to Cross-Site Scripting (XSS) vulnerabilities. Ensure to escape episode_location before embedding it into the HTML.

%>
${text}
</td>
Expand Down Expand Up @@ -523,7 +523,7 @@
% endif
${epResult["name"]}
</td>
<td class="col-name location">${epLoc}</td>
<td class="col-name location">${episode_location}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The display of episode_location directly in the HTML could lead to Cross-Site Scripting (XSS) vulnerabilities if the variable contains untrusted data. Ensure episode_location is properly sanitized or escaped before being rendered.

<td class="col-ep size">
% if epResult["file_size"]:
${pretty_file_size(epResult["file_size"])}
Expand Down
2 changes: 1 addition & 1 deletion sickchill/gui/slick/views/editShow.mako
Expand Up @@ -79,7 +79,7 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc">
<input type="hidden" name="show" id="showID" value="${show.indexerid}" />
<input type="text" name="location" id="location" value="${show._location}"
<input type="text" name="location" id="location" value="${show.get_location}"
class="form-control input-sm input350"
autocapitalize="off" title="Location" />
</div>
Expand Down
42 changes: 21 additions & 21 deletions sickchill/gui/slick/views/layouts/main.mako
Expand Up @@ -120,19 +120,19 @@
<nav class="navbar navbar-default navbar-fixed-top hidden-print">
<div class="container-fluid">
<%
numCombined = numErrors + numWarnings + settings.NEWS_UNREAD
if numCombined:
if numErrors:
total_warning_error_count = error_count + warning_count + settings.NEWS_UNREAD
if total_warning_error_count:
if error_count:
toolsBadgeClass = ' btn-danger'
elif numWarnings:
elif warning_count:
toolsBadgeClass = ' btn-warning'
else:
toolsBadgeClass = ''
%>
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapsible-navbar">
% if numCombined:
<span class="floating-badge${ toolsBadgeClass }">${ str(numCombined) }</span>
% if total_warning_error_count:
<span class="floating-badge${ toolsBadgeClass }">${ str(total_warning_error_count) }</span>
% endif
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
Expand All @@ -142,7 +142,7 @@
<a class="navbar-brand" href="${static_url('home/', include_version=False)}" title="SickChill"><img alt="SickChill" src="${static_url('images/sickchill.png')}"
class="img-responsive pull-left" /></a>
</div>
% if scLogin:
% if current_user:
<div class="collapse navbar-collapse" id="collapsible-navbar">
<ul class="nav navbar-nav navbar-right">
<%block name="navbar" />
Expand Down Expand Up @@ -243,8 +243,8 @@
else:
newsBadge = ''

if numCombined:
toolsBadge = ' <span class="badge'+toolsBadgeClass+'">'+str(numCombined)+'</span>'
if total_warning_error_count:
toolsBadge = ' <span class="badge'+toolsBadgeClass+'">'+str(total_warning_error_count)+'</span>'
else:
toolsBadge = ''
%>
Expand All @@ -260,26 +260,26 @@
<li><a href="${static_url('changes/', include_version=False)}"><i class="fa fa-fw fa-globe"></i>&nbsp;${_('Changelog')}</a></li>
<li><a href="${anon_url('https://github.com/SickChill/SickChill/wiki/Donations')}" rel="noreferrer" target="_blank"><i class="fa fa-fw fa-life-ring"></i>&nbsp;${_('Support SickChill')}</a></li>
<li role="separator" class="divider"></li>
%if numErrors:
<li><a href="${static_url('errorlogs/', include_version=False)}"><i class="fa fa-fw fa-exclamation-circle"></i>&nbsp;${_('View Errors')} <span class="badge btn-danger">${numErrors}</span></a></li>
%if error_count:
<li><a href="${static_url('errorlogs/', include_version=False)}"><i class="fa fa-fw fa-exclamation-circle"></i>&nbsp;${_('View Errors')} <span class="badge btn-danger">${error_count}</span></a></li>
%endif
%if numWarnings:
%if warning_count:
<li>
<a href="${static_url('errorlogs/?level={}'.format(logger.WARNING), include_version=False)}">
<i class="fa fa-fw fa-exclamation-triangle"></i>&nbsp;${_('View Warnings')} <span class="badge btn-warning">${numWarnings}</span>
<i class="fa fa-fw fa-exclamation-triangle"></i>&nbsp;${_('View Warnings')} <span class="badge btn-warning">${warning_count}</span>
</a>
</li>
%endif
<li><a href="${static_url('errorlogs/viewlog/', include_version=False)}"><i class="fa fa-fw fa-file-text-o"></i>&nbsp;${_('View Log')}</a></li>
<li role="separator" class="divider"></li>
% if hasattr(settings, "DISABLE_UPDATER") and not settings.DISABLE_UPDATER:
<li><a href="${static_url('home/updateCheck?pid={}'.format(scPID), include_version=False)}"><i class="fa fa-fw fa-wrench"></i>&nbsp;${_('Check For Updates')}</a></li>
<li><a href="${static_url('home/updateCheck?pid={}'.format(process_id), include_version=False)}"><i class="fa fa-fw fa-wrench"></i>&nbsp;${_('Check For Updates')}</a></li>
% endif
<li><a href="${static_url('home/restart/?pid={}'.format(scPID), include_version=False)}" class="confirm restart"><i
<li><a href="${static_url('home/restart/?pid={}'.format(process_id), include_version=False)}" class="confirm restart"><i
class="fa fa-fw fa-repeat"></i>&nbsp;${_('Restart')}</a></li>
<li><a href="${static_url('home/shutdown/?pid={}'.format(scPID), include_version=False)}" class="confirm shutdown"><i
<li><a href="${static_url('home/shutdown/?pid={}'.format(process_id), include_version=False)}" class="confirm shutdown"><i
class="fa fa-fw fa-power-off"></i>&nbsp;${_('Shutdown')}</a></li>
% if scLogin:
% if current_user:
<li><a href="${static_url('logout', include_version=False)}" class="confirm logout"><i class="fa fa-fw fa-sign-out"></i>&nbsp;${_('Logout')}</a></li>
% endif
<li role="separator" class="divider"></li>
Expand Down Expand Up @@ -320,7 +320,7 @@
</div>
% endif
<div class="clearfix"></div>
% if scLogin:
% if current_user:
<div id="site-messages"></div>
% endif
</div>
Expand Down Expand Up @@ -349,7 +349,7 @@
</div>
</div>

% if scLogin:
% if current_user:
<div class="row">
<div class="footer clearfix col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1 col-sm-12 col-xs-12">
<%
Expand Down Expand Up @@ -382,8 +382,8 @@
% if resource:
<span class="footer-item">${_('Memory used')}: <span class="footerhighlight">${pretty_file_size(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss*1024)}</span></span> |
% endif
<span class="footer-item">${_('Load time')}: <span class="footerhighlight">${"{:.4f}".format(time() - sbStartTime)}s</span></span> |
<span class="footer-item">Mako: <span class="footerhighlight">${"{:.4f}".format(time() - makoStartTime)}s</span></span> |
<span class="footer-item">${_('Load time')}: <span class="footerhighlight">${"{:.4f}".format(time() - page_load_start_time)}s</span></span> |
<span class="footer-item">Mako: <span class="footerhighlight">${"{:.4f}".format(time() - mako_load_start_time)}s</span></span> |
<span class="footer-item">${_('Version')}: <span class="footerhighlight">${get_current_version()}</span></span> |
<span class="footer-item">${_('Now')}: <span class="footerhighlight">${datetime.datetime.now().strftime(settings.DATE_PRESET+" "+settings.TIME_PRESET)}</span></span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sickchill/gui/slick/views/manage.mako
Expand Up @@ -109,7 +109,7 @@
<td class="text-center">${statusStrings[curShow.default_ep_status]}</td>
<td class="text-center">${_(curShow.status)}</td>

<td class="text-center">${curShow._location.rsplit('\\', 1)[0]}</td>
<td class="text-center">${curShow.get_location.rsplit('\\', 1)[0]}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of get_location method without error handling or checking if the method exists.

<td class="text-center">
<% disabled = settings.showQueueScheduler.action.is_being_updated(curShow) or settings.showQueueScheduler.action.is_in_update_queue(curShow) %>
<label for="update-${curShow.indexerid}" class="sr-only">${_('Update')} ${curShow.name}</label>
Expand Down