Skip to content

Commit

Permalink
flake8 and isort linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bbilly1 committed Sep 18, 2021
1 parent d2d6835 commit ef64100
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 86 deletions.
10 changes: 5 additions & 5 deletions tubearchivist/config/settings.py
Expand Up @@ -10,8 +10,8 @@
https://docs.djangoproject.com/en/3.2/ref/settings/
"""

from pathlib import Path
from os import environ
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -91,16 +91,16 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', # noqa: E501
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', # noqa: E501
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', # noqa: E501
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', # noqa: E501
},
]

Expand Down
2 changes: 1 addition & 1 deletion tubearchivist/config/urls.py
Expand Up @@ -14,7 +14,7 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import include, path

urlpatterns = [
path('', include('home.urls')),
Expand Down
8 changes: 3 additions & 5 deletions tubearchivist/home/src/download.py
Expand Up @@ -6,18 +6,16 @@
"""

import json
import shutil
import os

import shutil
from datetime import datetime
from time import sleep

import requests
import yt_dlp as youtube_dl

from home.src.index import YoutubeChannel, index_new_video
from home.src.config import AppConfig
from home.src.helper import clean_string, DurationConverter, set_message
from home.src.helper import DurationConverter, clean_string, set_message
from home.src.index import YoutubeChannel, index_new_video


class PendingList:
Expand Down
2 changes: 1 addition & 1 deletion tubearchivist/home/src/helper.py
Expand Up @@ -10,8 +10,8 @@
import subprocess
import unicodedata

import requests
import redis
import requests

REDIS_HOST = os.environ.get('REDIS_HOST')

Expand Down
7 changes: 2 additions & 5 deletions tubearchivist/home/src/index.py
Expand Up @@ -6,19 +6,16 @@
"""

import json
import os
import re

from datetime import datetime
from time import sleep
import os

import requests
import yt_dlp as youtube_dl

from bs4 import BeautifulSoup

from home.src.config import AppConfig
from home.src.helper import clean_string, DurationConverter
from home.src.helper import DurationConverter, clean_string


class YoutubeChannel:
Expand Down
3 changes: 0 additions & 3 deletions tubearchivist/home/src/index_management.py
Expand Up @@ -9,14 +9,11 @@
import json
import os
import zipfile

from datetime import datetime

import requests

from home.src.config import AppConfig


# expected mapping and settings
INDEX_CONFIG = [
{
Expand Down
26 changes: 8 additions & 18 deletions tubearchivist/home/src/reindex.py
Expand Up @@ -8,28 +8,18 @@
import json
import os
import re
import subprocess
import shutil

import subprocess
from datetime import datetime
from time import sleep
from math import ceil
from time import sleep

import requests

from home.src.download import ChannelSubscription, PendingList, VideoDownloader
from home.src.config import AppConfig
from home.src.index import (
YoutubeChannel,
YoutubeVideo,
index_new_video
)
from home.src.helper import (
get_total_hits,
clean_string,
set_message,
get_message
)
from home.src.download import ChannelSubscription, PendingList, VideoDownloader
from home.src.helper import (clean_string, get_message, get_total_hits,
set_message)
from home.src.index import YoutubeChannel, YoutubeVideo, index_new_video


class Reindex:
Expand Down Expand Up @@ -430,7 +420,7 @@ def move_to_cache(self, video_path, youtube_id):
video_file, ext = os.path.splitext(file_name)

# make sure youtube_id is in filename
if not youtube_id in video_file:
if youtube_id not in video_file:
video_file = f'{video_file}_{youtube_id}'

# move, convert if needed
Expand All @@ -444,7 +434,7 @@ def move_to_cache(self, video_path, youtube_id):
dest_path = os.path.join(self.CACHE_DIR, 'download', new_file)
subprocess.run(
["ffmpeg", "-i", video_path, dest_path,
"-loglevel", "warning", "-stats"], check=True
"-loglevel", "warning", "-stats"], check=True
)


Expand Down
5 changes: 1 addition & 4 deletions tubearchivist/home/src/searching.py
Expand Up @@ -9,14 +9,11 @@
import math
import os
import urllib.parse

from datetime import datetime

import requests

from PIL import Image

from home.src.config import AppConfig
from PIL import Image


class SearchHandler:
Expand Down
13 changes: 4 additions & 9 deletions tubearchivist/home/tasks.py
Expand Up @@ -7,17 +7,11 @@
import os

from celery import Celery, shared_task

from home.src.download import (
PendingList,
ChannelSubscription,
VideoDownloader
)
from home.src.config import AppConfig
from home.src.reindex import reindex_old_documents, ManualImport
from home.src.index_management import backup_all_indexes
from home.src.download import ChannelSubscription, PendingList, VideoDownloader
from home.src.helper import get_lock

from home.src.index_management import backup_all_indexes
from home.src.reindex import ManualImport, reindex_old_documents

CONFIG = AppConfig().config
REDIS_HOST = CONFIG['application']['REDIS_HOST']
Expand Down Expand Up @@ -94,6 +88,7 @@ def run_manual_import():
if have_lock:
my_lock.release()


@shared_task
def run_backup():
""" called from settings page, dump backup to zip file """
Expand Down
17 changes: 6 additions & 11 deletions tubearchivist/home/urls.py
@@ -1,16 +1,8 @@
""" all home app urls """

from django.urls import path

from home.views import (
HomeView,
DownloadView,
ChannelView,
ChannelIdView,
VideoView,
SettingsView,
AboutView
)
from home.views import (AboutView, ChannelIdView, ChannelView, DownloadView,
HomeView, SettingsView, VideoView)

from . import views

Expand All @@ -22,6 +14,9 @@
path('process/', views.process, name='process'),
path('downloads/progress', views.progress, name='progress'),
path('channel/', ChannelView.as_view(), name='channel'),
path('channel/<slug:channel_id_detail>/', ChannelIdView.as_view(), name='channel_id'),
path(
'channel/<slug:channel_id_detail>/',
ChannelIdView.as_view(), name='channel_id'
),
path('video/<slug:video_id>/', VideoView.as_view(), name='video')
]
31 changes: 9 additions & 22 deletions tubearchivist/home/views.py
Expand Up @@ -4,36 +4,23 @@
- process post data received from frontend via ajax
"""

import urllib.parse
import json

import urllib.parse
from datetime import datetime
from time import sleep

import requests

from django.shortcuts import render, redirect
from django.http import JsonResponse
from django.views import View
from django.shortcuts import redirect, render
from django.utils.http import urlencode

from home.src.download import PendingList, ChannelSubscription
from home.src.searching import SearchHandler, Pagination
from django.views import View
from home.src.config import AppConfig
from home.src.helper import (
process_url_list,
get_dl_message,
get_message,
set_message
)
from home.tasks import (
update_subscribed,
download_pending,
extrac_dl,
download_single,
run_manual_import,
run_backup
)
from home.src.download import ChannelSubscription, PendingList
from home.src.helper import (get_dl_message, get_message, process_url_list,
set_message)
from home.src.searching import Pagination, SearchHandler
from home.tasks import (download_pending, download_single, extrac_dl,
run_backup, run_manual_import, update_subscribed)


class HomeView(View):
Expand Down
1 change: 1 addition & 0 deletions tubearchivist/manage.py
Expand Up @@ -5,6 +5,7 @@


def main():
# pylint: disable=import-outside-toplevel
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
try:
Expand Down
5 changes: 3 additions & 2 deletions version_check.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python
""" check requirements.txt for outdated packages """

import sys
import pathlib
import sys

import requests

Expand Down Expand Up @@ -39,7 +39,7 @@ def get_dependencies(self):
package, version = dependency.split('==')
all_requirements.append((package, version.strip()))

all_requirements.sort(key = lambda x: x[0].lower())
all_requirements.sort(key=lambda x: x[0].lower())

return all_requirements

Expand Down Expand Up @@ -113,5 +113,6 @@ def main():
print('cancle update...')
sys.exit(1)


if __name__ == "__main__":
main()

0 comments on commit ef64100

Please sign in to comment.