Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
BluABK committed Apr 15, 2019
2 parents 94001e0 + bfc7229 commit d1d039e
Show file tree
Hide file tree
Showing 72 changed files with 375 additions and 507 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
Current
- Hotfix: disabled elision by default and instead explicitly using it during init only, due to VideoTileLabel.width()
changing drastically later on.
- Deleted deprecated debug_functions and cli arg --debug_open_1k_fds that was used for "too many file descriptors"
debugging.
- Moved log_handler into handlers package.
- Moved plaintext_history_handler into handlers package.
- Moved default_application_handler into handlers package.
- Made pickle load callers handle and log ModuleNotFound (happens when restructuring) and unexpected exceptions.
- Moved more path constants out of classes and into absolute_paths.
- Moved misplaced logdir up to the project root level (was in sources root).
- Refactored lots of manual OS_PATH cases to use absolute_paths instead.
- Fixed config_handler OS_PATH pointing at wrong level after move.
- Fixed orphaned settings import of ROOT_PATH in main_window (due to abs path move).
- Moved history_handler into handlers package and renamed with suffix 'plaintext'.
- Moved config_handler into handlers package.
- Moved pickle_handler into handlers package.
- Moved (Youtube auth) generate_keys into youtube folder.
- Moved (YouTube API) authentication into youtube folder.
- Removed deprecated show_grab_method debug option and code.
- Made Title, Channel and Date VideoTile labels part of a class VideoTileLabel to avoid excessively redundant code.

v0.6.1
- Removed no longer necessary pixel size hacks from config.
Expand Down
2 changes: 1 addition & 1 deletion __main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import runpy

from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger

if __name__ == "__main__":
logger = create_logger(__name__)
Expand Down
1 change: 0 additions & 1 deletion config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ start_with_stored_videos = False
channels_limit = -1
use_playlistitems = True
disable_tooltips = False
show_grab_method = False
show_unimplemented_gui = False
display_all_exceptions = False
color_tile_elements = False
Expand Down
1 change: 1 addition & 0 deletions hotkeys.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ detailed_list = Ctrl+3
download = Ctrl+4
subscriptions = Ctrl+5
tiled_list = Ctrl+9
config = Ctrl+P

[Subfeed]
download = LeftButton
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ pathtools==0.1.2
Pillow==5.2.0
pyasn1==0.4.3
pyasn1-modules==0.2.2
PyQt5==5.11.2
PyQt5-sip==4.19.11
PyQt5>=5.11.2
PyQt5-sip>=4.19.11
python-dateutil==2.7.3
python-editor==1.0.3
PyYAML==4.2b4
PyYAML>=4.2b4
requests==2.21.0
requests-oauthlib==1.0.0
rsa==3.4.2
Expand Down
15 changes: 9 additions & 6 deletions sane_yt_subfeed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import shutil # For file copying
from PyQt5 import QtCore

from sane_yt_subfeed.absolute_paths import HISTORY_FILE_PATH, LOG_DIR
from sane_yt_subfeed.database.orm import init_db
from sane_yt_subfeed.history_handler import HISTORY_FILEPATH
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger

# FIXME: module level logger not suggested: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
logger = create_logger(__name__)
logger.info("Initializing...")

Expand All @@ -15,12 +13,14 @@
PICKLE_PATH = os.path.join(OS_PATH, 'resources', 'pickles')
THUMBNAIL_PATH = os.path.join(OS_PATH, 'resources', 'thumbnails')

# Required on windows (w/ virtualenv)
PYQT_PATH = os.path.join(OS_PATH, '..', 'env', 'Lib', 'site-packages', 'PyQt5', 'Qt', 'plugins')
PYQT_PATH2 = os.path.join(OS_PATH, 'env', 'Lib', 'site-packages', 'PyQt5', 'Qt', 'plugins')

QtCore.QCoreApplication.addLibraryPath(PYQT_PATH)
QtCore.QCoreApplication.addLibraryPath(PYQT_PATH2)

# Initialize database
init_db()

# Make sure dirs exists on startup
Expand All @@ -30,6 +30,9 @@
if not os.path.isdir(THUMBNAIL_PATH):
os.makedirs(THUMBNAIL_PATH)

if not os.path.isdir(LOG_DIR):
os.makedirs(LOG_DIR)

# Make sure files exists on startup
if not os.path.isfile(HISTORY_FILEPATH):
open(HISTORY_FILEPATH, 'a').close()
if not os.path.isfile(HISTORY_FILE_PATH):
open(HISTORY_FILE_PATH, 'a').close()
4 changes: 2 additions & 2 deletions sane_yt_subfeed/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sane_yt_subfeed.cli import cli
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.run import cli
from sane_yt_subfeed.handlers.log_handler import create_logger

logger = create_logger(__name__)

Expand Down
52 changes: 48 additions & 4 deletions sane_yt_subfeed/absolute_paths.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
import os

OS_PATH = os.path.dirname(__file__)
ICONS_PATH = os.path.join(OS_PATH, 'resources', 'icons')
RESOURCES_PATH = os.path.join(OS_PATH, 'resources')
VERSION_PATH = os.path.join(OS_PATH, '..', 'VERSION')
# Backend
ROOT_PATH = os.path.dirname(__file__)
PROJECT_ROOT_PATH = os.path.join(ROOT_PATH, '..')
RESOURCES_PATH = os.path.join(ROOT_PATH, 'resources')
IMG_PATH = os.path.join(ROOT_PATH, 'images')

# Database
DATABASE_PATH = os.path.join(RESOURCES_PATH, 'permanents.db')

# Config
CONFIG_PATH = os.path.join(PROJECT_ROOT_PATH, 'config.ini')
CONFIG_HOTKEYS_PATH = os.path.join(PROJECT_ROOT_PATH, 'hotkeys.ini')
SAMPLE_HOTKEYS_PATH = os.path.join(PROJECT_ROOT_PATH, 'hotkeys.ini.sample')
SAMPLE_PATH = os.path.join(PROJECT_ROOT_PATH, 'config.ini.sample')

# Logs
LOG_DIR = os.path.join(PROJECT_ROOT_PATH, 'logs')

# Plaintext history
HISTORY_FILE_PATH = os.path.join(LOG_DIR, 'history.txt')

# Pickler
PICKLE_PATH = os.path.join(RESOURCES_PATH, 'pickles')
YOUTUBE_RESOURCE_OAUTH_PICKLE = os.path.join(PICKLE_PATH, 'youtube_oauth.pkl')
YOUTUBE_RESOURCE_KEYS_PICKLE = os.path.join(PICKLE_PATH, 'youtube_auth_keys.pkl')

# YouTube
CLIENT_SECRET_FILE = os.path.join(RESOURCES_PATH, 'client_secret.json')
CLIENT_SECRET_PUBLIC_FILE = os.path.join(RESOURCES_PATH, "client_secret_public.json")
KEYS_FILE = os.path.join(RESOURCES_PATH, 'keys.json')
KEYS_PULIC_FILE = os.path.join(RESOURCES_PATH, "keys_public.json")

THUMBNAILS_PATH = os.path.join(RESOURCES_PATH, 'thumbnails')
THUMBNAILS_RESIZED_PATH = os.path.join(THUMBNAILS_PATH, 'resized')
THUMBNAIL_NA_PATH = os.path.join(RESOURCES_PATH, 'thumbnail_na.png')
THUMBNAIL_404_PATH = os.path.join(RESOURCES_PATH, 'quality404.jpg')

# GUI
ICONS_PATH = os.path.join(RESOURCES_PATH, 'icons')
VERSION_PATH = os.path.join(PROJECT_ROOT_PATH, 'VERSION')
OVERLAY_NEW_PATH = os.path.join(ICONS_PATH, 'new_vid.png')
OVERLAY_MISSED_PATH = os.path.join(ICONS_PATH, 'missed_vid.png')
OVERLAY_DOWNLOADED_PATH = os.path.join(ICONS_PATH, 'downloaded_vid.png')
OVERLAY_DISCARDED_PATH = os.path.join(ICONS_PATH, 'dismissed.png')
OVERLAY_WATCHED_PATH = os.path.join(ICONS_PATH, 'watched.png')
OVERLAY_NO_FILE_PATH = os.path.join(ICONS_PATH, 'no_file.png')
ABOUT_IMG_PATH = os.path.join(IMG_PATH, 'about.png')
DUMMY_ICO_PATH = os.path.join(ICONS_PATH, 'dummies')
Empty file added sane_yt_subfeed/cli/__init__.py
Empty file.
File renamed without changes.
7 changes: 7 additions & 0 deletions sane_yt_subfeed/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Backend (mostly)
YOUTUBE_URL_BASE = "https://www.youtube.com/"
YOUTUBE_URL_PART_VIDEO = "watch?v="
YOUTUBE_URL_PART_PLIST = "playlist?list ="
YOUTUBE_URL_VIDEO = YOUTUBE_URL_BASE + YOUTUBE_URL_PART_VIDEO

# GUI
RESTART_REQUIRED_SIGNIFIER = '<b>*</b>' # ' <b><font color=gold>*</font></b>'
HEXADECIMAL_COLOR_REGEX = '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$'
4 changes: 2 additions & 2 deletions sane_yt_subfeed/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication

from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.controller.view_models import MainModel
from sane_yt_subfeed.gui.main_window.main_window import MainWindow
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger


class Controller:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from PyQt5.QtCore import *

from sane_yt_subfeed import main
from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.controller.listeners.gui.views.download_view.download_view_listener import DownloadViewListener
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger
from sane_yt_subfeed.youtube.thumbnail_handler import download_thumbnails_threaded
from sane_yt_subfeed.youtube.update_videos import load_keys
from sane_yt_subfeed.youtube.youtube_requests import get_remote_subscriptions_cached_oauth, \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import gc
import time

from PyQt5.QtCore import *
from PyQt5.QtGui import QPalette

from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger


class ProgressBarListener(QObject):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy import false

from sane_yt_subfeed import create_logger
from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
import sane_yt_subfeed.controller.listeners.gui.views.grid_view.static_grid_view_listener as static_grid_view_listener
from sane_yt_subfeed.database.db_download_tile import DBDownloadTile
from sane_yt_subfeed.database.detached_models.d_db_download_tile import DDBDownloadTile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import time
from PyQt5.QtCore import QObject, pyqtSlot

from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot

from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
# from sane_yt_subfeed.controller.listeners.gui.views.download_view.download_view_listener import DownloadViewListener
from sane_yt_subfeed.database.video import Video
from sane_yt_subfeed.database.write_operations import UpdateVideo
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger
from sane_yt_subfeed.database.detached_models.video_d import VideoD
# import sane_yt_subfeed.controller.listeners.gui.views.grid_view.static_grid_view_listener as static_grid_view_listener

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyQt5.QtCore import pyqtSignal, pyqtSlot

from sane_yt_subfeed import create_logger
from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.controller.listeners.gui.views.grid_view.grid_view_listener import GridViewListener
from sane_yt_subfeed.controller.listeners.gui.views.download_view.download_view_listener import DownloadViewListener
from sane_yt_subfeed.database.detached_models.video_d import VideoD
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import gc
import time

import datetime
import os
from PyQt5.QtCore import *
from watchdog.observers import Observer

from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.controller.dir_handler import VidEventHandler, CheckYoutubeFolderForNew
from sane_yt_subfeed.database.orm import db_session
from sane_yt_subfeed.database.video import Video
from sane_yt_subfeed.database.write_operations import UpdateVideo
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger
from sane_yt_subfeed.youtube.thumbnail_handler import download_thumbnails_threaded, THUMBNAILS_PATH
from sane_yt_subfeed.youtube.update_videos import load_keys
from sane_yt_subfeed.youtube.youtube_requests import list_uploaded_videos_videos
Expand Down
6 changes: 3 additions & 3 deletions sane_yt_subfeed/controller/view_models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from PyQt5.QtCore import QThread, Qt
from PyQt5.QtCore import QThread
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import QProgressBar
from sqlalchemy import asc, desc, false, or_
from sqlalchemy.dialects import postgresql

from sane_yt_subfeed.config_handler import read_config, set_config
from sane_yt_subfeed.handlers.config_handler import read_config, set_config
from sane_yt_subfeed.controller.listeners.database.database_listener import DatabaseListener
from sane_yt_subfeed.controller.listeners.gui.main_window.main_window_listener import MainWindowListener
from sane_yt_subfeed.controller.listeners.gui.progress_bar.progress_bar_listener import ProgressBarListener
Expand All @@ -21,7 +21,7 @@
from sane_yt_subfeed.database.video import Video
from sane_yt_subfeed.database.write_operations import UpdateVideosThread
from sane_yt_subfeed.exceptions.sane_aborted_operation import SaneAbortedOperation
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger
from sane_yt_subfeed.youtube.thumbnail_handler import download_thumbnails_threaded


Expand Down
4 changes: 2 additions & 2 deletions sane_yt_subfeed/database/detached_models/video_d.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import datetime

from sane_yt_subfeed import create_logger
from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.settings import YOUTUBE_URL_BASE, YOUTUBE_URL_PART_VIDEO
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.constants import YOUTUBE_URL_BASE, YOUTUBE_URL_PART_VIDEO

GRAB_METHOD_LIST = 'list()'
GRAB_METHOD_SEARCH = 'search()'
Expand Down
4 changes: 2 additions & 2 deletions sane_yt_subfeed/database/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker

from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.handlers.log_handler import create_logger

# FIXME: module level logger not suggested: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
logger = create_logger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions sane_yt_subfeed/database/read_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import threading
from sqlalchemy import desc, asc

from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.controller.listeners.database.database_listener import DatabaseListener
from sane_yt_subfeed.controller.static_controller_vars import LISTENER_SIGNAL_NORMAL_REFRESH, \
LISTENER_SIGNAL_DEEP_REFRESH
Expand All @@ -11,7 +11,7 @@
from sane_yt_subfeed.database.video import Video
from sane_yt_subfeed.database.write_operations import UpdateVideosThread, UpdateVideosExtraInfoThreaded
from sane_yt_subfeed.exceptions.sane_aborted_operation import SaneAbortedOperation
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger
from sane_yt_subfeed.youtube.thumbnail_handler import download_thumbnails_threaded
from sane_yt_subfeed.youtube.update_videos import refresh_uploads, get_extra_videos_information

Expand Down
4 changes: 2 additions & 2 deletions sane_yt_subfeed/database/video.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import datetime
from sqlalchemy import Boolean, DateTime, Column, Integer, String, Interval

from sane_yt_subfeed.config_handler import read_config
from sane_yt_subfeed.handlers.config_handler import read_config
from sane_yt_subfeed.database.decorators import TextPickleType
from sane_yt_subfeed.database.detached_models.video_d import VideoD
# from sane_yt_subfeed.database.detached_models.video_d import VIDEO_KIND_VOD, VIDEO_KIND_LIVE, \
# VIDEO_KIND_LIVE_SCHEDULED, VIDEO_KIND_PREMIERE
from sane_yt_subfeed.database.orm import PermanentBase
from sane_yt_subfeed.settings import YOUTUBE_URL_BASE, YOUTUBE_URL_PART_VIDEO
from sane_yt_subfeed.constants import YOUTUBE_URL_BASE, YOUTUBE_URL_PART_VIDEO


class Video(PermanentBase): # FIXME: PickleTypes should probably be replaced by actual tables
Expand Down
2 changes: 1 addition & 1 deletion sane_yt_subfeed/database/write_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sane_yt_subfeed.database.models import Channel
from sane_yt_subfeed.database.orm import engine, db_session
from sane_yt_subfeed.database.video import Video
from sane_yt_subfeed.log_handler import create_logger
from sane_yt_subfeed.handlers.log_handler import create_logger

lock = threading.Lock()

Expand Down
Loading

0 comments on commit d1d039e

Please sign in to comment.