Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Cypher-O committed Aug 11, 2024
1 parent 0146585 commit 9b08f1d
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 30,142 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ __pycache__/

# IDEs and editors
.vscode/

# log
vlc-log.txt
2 changes: 1 addition & 1 deletion recent_media.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[Recent]
files = /home/novaji/Downloads/Olumide/Suits/Suits.S07.1080p.BluRay.x265-RARBG/Suits.S07E16.1080p.BluRay.x265-RARBG.mp4|/home/novaji/Downloads/Olumide/Power.Book.II.Ghost.S04E02.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Lupin.SEASON.03.S03.COMPLETE.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA/Lupin.S03E04.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/React Portfolio Website Tutorial - Portfolio Website Using React - React JS Portfolio Website.mp4|/home/novaji/Downloads/Olumide/Flutter Agora Video Call.mp4|/home/novaji/Downloads/Olumide/Lupin.SEASON.03.S03.COMPLETE.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA/Lupin.S03E01.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Videos/Screencasts/Screencast from 2024-06-22 01-34-24.mp4|/home/novaji/Downloads/Olumide/Lupin.SEASON.03.S03.COMPLETE.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA/Lupin.S03E02.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Lupin.SEASON.03.S03.COMPLETE.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA/Lupin.S03E03.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Lupin.SEASON.03.S03.COMPLETE.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA/Lupin.S03E05.DUAL-AUDIO.FRE-ENG.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv
files = /home/novaji/Downloads/Olumide/BLACK DYNAMTE (2011-2015) - Completed ANIMATED TV Series and 2009 Movie - 1080p x264/Specials (2011)/BLACK Dynamite - S00 E01 - Trouble on Puppet Street (1080p - Web-DL).mp4|/home/novaji/Downloads/Olumide/Power.Book.II.Ghost.S04E01.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/The.Boys.2019.S04E02.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/The.Boys.2019.S04E01.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/The.Boys.2019.S04E03.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/House.of.the.Dragon.S02E01.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Mayor.of.Kingstown.S03E03.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Mayor.of.Kingstown.S03E01.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Mayor.of.Kingstown.S03E02.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv|/home/novaji/Downloads/Olumide/Power.Book.II.Ghost.S04E02.1080p.10bit.WEBRip.6CH.x265.HEVC-PSA.mkv

91 changes: 1 addition & 90 deletions src/controller/video_controller.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import os
import sys
import vlc
import ctypes
import logging
import os, sys, vlc, ctypes, logging, random, configparser
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QDialog, QComboBox, QLabel, QSlider, QProgressBar, QPushButton, QVBoxLayout, QHBoxLayout, QAction, QMenuBar
from PyQt5.QtCore import QTimer, QDir, Qt
import random
import configparser
from view.codec_info_dialog import CodecInfoDialog
from view.preferences_dialog import PreferencesDialog
from utils.config import *


class VideoController:
def __init__(self, view):
self.view = view
Expand Down Expand Up @@ -272,44 +265,6 @@ def update_subtitle_tracks(self):

print(f"Total subtitle options (including 'No subtitles'): {len(self.subtitle_tracks)}")
self.view.subtitle_combo.setEnabled(len(self.subtitle_tracks) > 1)


# def get_codec_info(self):
# if self.media_player.is_playing() or self.media_player.get_state() == vlc.State.Paused:
# media = self.media_player.get_media()
# media.parse()

# codec_info = []
# tracks = media.tracks_get()
# print("Available methods and attributes of media object:")
# print(dir(media))
# for i, track in enumerate(tracks):
# codec_info.append(f"Track {i}:")
# codec_info.append(f" Type: {track.type}")

# # Safely get codec information
# codec = getattr(track, 'codec', None)
# if codec:
# codec_info.append(f" Codec: {codec}")

# # Safely get codec description
# codec_description = getattr(track, 'codec_description', None)
# if codec_description:
# codec_info.append(f" Codec Description: {codec_description}")

# # Add any other attributes that might be useful and available
# for attr in ['bitrate', 'width', 'height', 'fps', 'channels']:
# value = getattr(track, attr, None)
# if value is not None:
# codec_info.append(f" {attr.capitalize()}: {value}")

# codec_info.append("")

# # Removed: media.tracks_release()
# return codec_info
# else:
# return ["No media playing"]


def get_codec_info(self):
if self.media_player.is_playing() or self.media_player.get_state() == vlc.State.Paused:
Expand Down Expand Up @@ -381,50 +336,6 @@ def get_codec_info(self):
else:
return ["No media playing"]



# def get_codec_info(self):
# if self.media_player.is_playing() or self.media_player.get_state() == vlc.State.Paused:
# media = self.media_player.get_media()
# media.parse()

# codec_info = []

# # Add general media information
# codec_info.append("General Media Information:")
# codec_info.append(f" Duration: {media.get_duration()} ms")
# codec_info.append(f" State: {media.get_state()}")

# try:
# stats = media.get_stats()
# codec_info.append(" Statistics:")
# for key, value in stats.__dict__.items():
# if value is not None and not key.startswith('_'):
# codec_info.append(f" {key.capitalize()}: {value}\n")
# except Exception as e:
# codec_info.append(f" Error retrieving media statistics: {str(e)}")

# try:
# tracks = media.tracks_get()
# for i, track in enumerate(tracks):
# codec_info.append(f"Track {i}:")
# codec_info.append(f" Type: {track.type}")

# # Get all available attributes
# track_info = track.__dict__
# for key, value in track_info.items():
# if value is not None and key not in ['_as_parameter_', 'contents']:
# codec_info.append(f" {key.capitalize()}: {value}")

# codec_info.append("")

# except Exception as e:
# codec_info.append(f"Error retrieving track information: {str(e)}")

# return codec_info
# else:
# return ["No media playing"]

def show_codec_info(self):
codec_info = self.get_codec_info()
dialog = CodecInfoDialog(codec_info, self.view)
Expand Down
1 change: 0 additions & 1 deletion src/view/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
class AboutDialog(QDialog):
def __init__(self):
super().__init__()
self.center()
self.setWindowTitle(ABOUT)
self.setGeometry(100, 100, 400, 300)
layout = QVBoxLayout()
Expand Down
16 changes: 0 additions & 16 deletions src/view/codec_info_dialog.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel

# class CodecInfoDialog(QDialog):
# def __init__(self, codec_info, parent=None):
# super().__init__(parent)
# self.setWindowTitle("Codec Information")
# self.setGeometry(100, 100, 400, 300)
# layout = QVBoxLayout()

# for info in codec_info:
# label = QLabel(info)
# layout.addWidget(label)

# self.setLayout(layout)


from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QScrollArea, QWidget
from PyQt5.QtCore import Qt

Expand Down
136 changes: 1 addition & 135 deletions src/view/playlist_dialog.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QListWidget, QPushButton, QHBoxLayout, QListWidgetItem
import os
from controller.video_controller import VideoController
# from view.video_player import center

class PlaylistDialog(QDialog):
def __init__(self, parent, playlist):
super().__init__(parent)
self.setWindowTitle("Playlist")
# self.layout.center()
self.setGeometry(100, 100, 300, 400)

self.parent = parent
Expand Down Expand Up @@ -40,15 +38,6 @@ def __init__(self, parent, playlist):

# Connect the itemClicked signal to the slot method
self.playlist_widget.itemClicked.connect(self.handle_playlist_item_click)

# def update_playlist(self, playlist):
# # self.playlist_widget.clear()
# if not playlist:
# self.playlist_widget.addItem("No queue added to the playlist")
# else:
# for file in enumerate(playlist):
# item = QListWidgetItem(f"{os.path.basename(file)}")
# self.playlist_widget.addItem(item)

def update_playlist(self, playlist=None):
if playlist is not None:
Expand Down Expand Up @@ -93,13 +82,6 @@ def add_media(self):
print(f"Error adding new file to playlist: {file}")
print(f"Error details: {str(e)}")
self.playlist_widget.addItem(QListWidgetItem(str(file)))

# def remove_media(self):
# selected_items = self.playlist_widget.selectedItems()
# if not selected_items:
# return
# for item in selected_items:
# self.playlist_widget.takeItem(self.playlist_widget.row(item))

def remove_media(self):
selected_items = self.playlist_widget.selectedItems()
Expand Down Expand Up @@ -143,120 +125,4 @@ def handle_playlist_item_click(self, item):
if os.path.basename(file) == item_text:
self.parent.controller.playlist_index = i
self.parent.controller.play_media()
break


# from PyQt5.QtWidgets import QDialog, QVBoxLayout, QListWidget, QPushButton, QHBoxLayout, QListWidgetItem
# import os
# from controller.video_controller import VideoController

# class PlaylistDialog(QDialog):
# def __init__(self, parent, playlist):
# super().__init__(parent)
# self.setWindowTitle("Playlist")
# self.setGeometry(100, 100, 300, 400)

# self.parent = parent
# self.playlist = playlist

# self.layout = QVBoxLayout(self)

# self.playlist_widget = QListWidget(self)
# self.update_playlist(self.playlist)
# self.layout.addWidget(self.playlist_widget)

# self.button_layout = QHBoxLayout()
# self.layout.addLayout(self.button_layout)

# self.add_button = QPushButton("Add")
# self.add_button.clicked.connect(self.add_media)
# self.button_layout.addWidget(self.add_button)

# self.remove_button = QPushButton("Remove")
# self.remove_button.clicked.connect(self.remove_media)
# self.button_layout.addWidget(self.remove_button)

# self.clear_button = QPushButton("Clear")
# self.clear_button.clicked.connect(self.clear_playlist)
# self.button_layout.addWidget(self.clear_button)

# self.close_button = QPushButton("Close")
# self.close_button.clicked.connect(self.close)
# self.button_layout.addWidget(self.close_button)

# def update_playlist(self, playlist=None):
# if playlist is not None:
# self.playlist = playlist

# self.playlist_widget.clear()
# if not self.playlist:
# self.playlist_widget.addItem("No queue added to the playlist")
# else:
# for file in self.playlist:
# item_name = os.path.basename(file) if isinstance(file, str) else str(file)
# item = QListWidgetItem(item_name)
# self.playlist_widget.addItem(item)
# print(f"Updated playlist with {len(self.playlist)} items.")

# def add_media(self):
# initial_count = len(self.playlist)
# self.parent.controller.open_multiple_files()

# # Fetch the updated playlist from the controller
# controller_playlist = self.parent.controller.playlist
# new_files = controller_playlist[initial_count:]

# if new_files:
# print(f"New files detected: {new_files}")
# self.playlist.extend(new_files)
# self.append_to_playlist_widget(new_files)
# self.parent.controller.playlist = self.playlist # Sync back to the controller
# print(f"Added {len(new_files)} new items to the playlist. Total now: {len(self.playlist)}.")
# else:
# print("No new files detected. Playlist unchanged.")


# def append_to_playlist_widget(self, files):
# # Remove "No queue added to the playlist" if it exists
# if self.playlist_widget.count() == 1 and self.playlist_widget.item(0).text() == "No queue added to the playlist":
# self.playlist_widget.takeItem(0)

# for file in files:
# try:
# item_name = os.path.basename(file) if isinstance(file, str) else str(file)
# list_item = QListWidgetItem(item_name)
# self.playlist_widget.addItem(list_item)
# except Exception as e:
# print(f"Error adding new file to playlist: {file}")
# print(f"Error details: {str(e)}")
# self.playlist_widget.addItem(QListWidgetItem(str(file)))
# print(f"Appended {len(files)} items to the playlist widget. Total in widget now: {self.playlist_widget.count()}.")

# def remove_media(self):
# selected_items = self.playlist_widget.selectedItems()
# if not selected_items:
# return

# items_to_remove = []
# for item in selected_items:
# index = self.playlist_widget.row(item)
# if 0 <= index < len(self.playlist):
# items_to_remove.append(index)

# for index in sorted(items_to_remove, reverse=True):
# del self.playlist[index]

# self.update_playlist(self.playlist)
# self.parent.controller.playlist = self.playlist # Sync back to the controller
# print(f"Removed {len(items_to_remove)} items. Total now: {len(self.playlist)}.")

# def clear_playlist(self):
# self.playlist.clear()
# self.update_playlist(self.playlist)
# self.parent.controller.playlist = self.playlist # Sync back to the controller
# print("Cleared playlist.")

# def closeEvent(self, event):
# self.parent.controller.playlist = self.playlist # Ensure syncing back to controller on close
# super().closeEvent(event)
# print("Playlist dialog closed.")
break
39 changes: 0 additions & 39 deletions src/view/preferences_dialog.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
# from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QFileDialog

# class PreferencesDialog(QDialog):
# def __init__(self, parent, current_preferences):
# super().__init__(parent)
# self.setWindowTitle("Preferences")
# self.current_preferences = current_preferences
# self.layout = QVBoxLayout()

# # Default video directory
# self.video_dir_layout = QHBoxLayout()
# self.video_dir_label = QLabel("Default Video Directory:")
# self.video_dir_edit = QLineEdit(self.current_preferences.get('default_video_dir', ''))
# self.video_dir_button = QPushButton("Browse")
# self.video_dir_button.clicked.connect(self.browse_video_dir)
# self.video_dir_layout.addWidget(self.video_dir_label)
# self.video_dir_layout.addWidget(self.video_dir_edit)
# self.video_dir_layout.addWidget(self.video_dir_button)
# self.layout.addLayout(self.video_dir_layout)

# # Add more preference options here

# # Save button
# self.save_button = QPushButton("Save")
# self.save_button.clicked.connect(self.save_preferences)
# self.layout.addWidget(self.save_button)

# self.setLayout(self.layout)

# def browse_video_dir(self):
# dir_name = QFileDialog.getExistingDirectory(self, "Select Default Video Directory")
# if dir_name:
# self.video_dir_edit.setText(dir_name)

# def save_preferences(self):
# self.current_preferences['default_video_dir'] = self.video_dir_edit.text()
# # Save more preferences here
# self.accept()

# preferences_dialog.py
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QCheckBox, QPushButton

Expand Down
Loading

0 comments on commit 9b08f1d

Please sign in to comment.