Skip to content

Commit

Permalink
Merge pull request #12 from Thomasedv/master
Browse files Browse the repository at this point in the history
Updating release branch to V4
  • Loading branch information
Thomasedv authored Feb 23, 2019
2 parents 69dd998 + 5df912b commit 30e5892
Show file tree
Hide file tree
Showing 9 changed files with 1,743 additions and 1,577 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
such as by intimate get_settings_data communication or control flow between those
subprograms and other parts of the work.

The Corresponding Source need not include anything that users
Expand Down
29 changes: 19 additions & 10 deletions Modules/download_tab.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtWidgets import QWidget, QPushButton, QLabel, QTextBrowser, QCheckBox, \
QHBoxLayout, QVBoxLayout

from Modules.dropdown_widget import DropDown
from Modules.lineEdit import LineEdit
from Modules.lineedit import LineEdit
from utils.utilities import SettingsClass


class MainTab(QWidget):

def __init__(self, settings, parent=None):
def __init__(self, settings: SettingsClass, parent=None):
super().__init__(parent=parent)

# Starts the program (Youtube-dl)
self.start_btn = QPushButton('Download')
self.start_btn.clicked.connect(self.start_button_timer)
# stops the program
self.stop_btn = QPushButton('Abort')
# Closes window (also stops the program)
Expand All @@ -27,10 +29,15 @@ def __init__(self, settings, parent=None):
self.profile_dropdown = DropDown(self)
self.profile_dropdown.setFixedWidth(100)

if settings['Profiles']:
for profile in settings['Profiles'].keys():
self.timer = QTimer(self)
self.timer.setInterval(100)
self.timer.setSingleShot(True)
self.timer.timeout.connect(lambda: self.start_btn.setDisabled(False))

if settings.profiles:
for profile in settings.profiles:
self.profile_dropdown.addItem(profile)
current_profile = settings['Other stuff']['current_profile']
current_profile = settings.user_options['current_profile']
if current_profile:
self.profile_dropdown.setCurrentText(current_profile)
else:
Expand All @@ -56,8 +63,6 @@ def __init__(self, settings, parent=None):
# Start making checkbutton for selecting downloading from text file mode.
self.checkbox = QCheckBox('Download from text file.')

## Layout tab 1.

# Contains, start, abort, close buttons, and a stretch to make buttons stay on the correct side on rezise.
self.QH = QHBoxLayout()

Expand Down Expand Up @@ -91,14 +96,18 @@ def __init__(self, settings, parent=None):

self.setLayout(self.QV)

def start_button_timer(self, state):
if not state:
self.timer.start(1000)


if __name__ == '__main__':
# Only visual aspects work here!!
import sys
from PyQt5.QtWidgets import QApplication
from utils.utilities import get_base_settings
from utils.filehandler import FileHandler

app = QApplication(sys.argv)
gui = MainTab(get_base_settings())
gui = MainTab(FileHandler().load_settings())
gui.show()
app.exec_()
File renamed without changes.
4 changes: 2 additions & 2 deletions Modules/parameterTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ParameterTree(QTreeWidget):
addOption = pyqtSignal(QTreeWidgetItem)
itemRemoved = pyqtSignal(QTreeWidgetItem, int)

def __init__(self, profile: dict):
def __init__(self, profile: dict, parent=None):
"""
Data table:
All data is in column 0.
Expand All @@ -30,7 +30,7 @@ def __init__(self, profile: dict):
37 - List of QModelIndex to items that this depends on.
"""
super().__init__()
super().__init__(parent=parent)

self.favorite = False

Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ If you want to convert the videos, or otherwise use features of youtube-dl that
that also has to be in the same folder (or path) as Grabber.**

You can get those programs here:
* Youtube-dl: https://rg3.github.io/youtube-dl/
* ffmpeg: https://www.ffmpeg.org/
* Youtube-dl: https://rg3.github.io/youtube-dl/
* ffmpeg: https://ffmpeg.zeranoe.com/builds/

Requirements to use source:
**USE THE 4.0.2 static ffmpeg version!** Extract the 3 executables from the bin folder to the Grabber folder or PATH

______

Requirements to use source code:

* Python 3.6+
* PyQt5 5.9 (Earlier version might work too, worked fine with 5.8 before i upgraded.)
Expand Down
22 changes: 17 additions & 5 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from PyQt5.QtWidgets import QApplication, QMessageBox

from core import GUI
from utils.utilities import SettingsError
from utils.filehandler import FileHandler
from utils.utilities import SettingsError, ProfileLoadError


def main():
Expand All @@ -21,13 +21,25 @@ def main():
if EXIT_CODE == GUI.EXIT_CODE_REBOOT:
continue

except (SettingsError, json.decoder.JSONDecodeError) as e:
except (SettingsError, ProfileLoadError, json.decoder.JSONDecodeError) as e:
if isinstance(e, ProfileLoadError):
file = 'profiles file'
else:
file = 'settings file'

warning = QMessageBox.warning(None,
'Corrupt settings',
''.join([str(e), '\nRestore default settings?']),
f'Corruption of {file}!',
''.join([str(e), '\nRestore to defaults?']),
buttons=QMessageBox.Yes | QMessageBox.No)

if warning == QMessageBox.Yes:
FileHandler().load_settings(True)
filehandler = FileHandler()
if isinstance(e, ProfileLoadError):
filehandler.save_profiles({})
else:
setting = filehandler.load_settings(reset=True)
filehandler.save_settings(setting.get_settings_data)

app = None # Ensures the app instance is properly removed!
continue

Expand Down
Loading

0 comments on commit 30e5892

Please sign in to comment.