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

Update latest-beta to 1.5.1b #5

Merged
merged 21 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
# PyMedia
A Python CLI/GUI based media player.
If you have any suggestions on how to improve the code or repeatedly run in to an error then please open an issue.
Also yes I am aware of the formatting issue with the readme, Github didn't wanna while I was editing this.
A Python based CLI and GUI media player. <br>
Feel free to open an issue for bugs, glitches, or suggestions. <br><br>
<b>This is a dev branch, you may run into bugs.</b>

# Already known issues
1. Alsa shitting out a warning sometimes
2. Help command still unavailable (I forgot to add this during release of v1.1.0)
1. ValueError upon trying to use any command directly after queue is empty. (Actual cause is not 100% known)
2. `exit` command doesn't exit fully when playing audio and will need to press ctrl+c in order to fully exit. (?)

# How to install
<h3>Windows</h3>
1. Install 7zip if you haven't already, the install file is actively available in the repo files. <br>
2. Use 7zip to unzip `ffmpeg.7z`. This file is important as it is required in YT-DLP
<h3>Ubuntu</h3>
1. Open your terminal application with ctrl+alt+t <br>
### Binaries
1. Go to <a href="https://github.com/BnDLett/PyMedia/releases/tag/v1.3.0a">PyMedia v1.3.0a pre-release</a> (or whatever version suits you best).
2. Download the binary for your platform.
3. (Recommended) Move the binary to an appropriate folder.
4. Run the binary.

## Installation from source
### Windows
1. Install 7zip if you haven't already, the install file is actively available in the repo files.
2. Use 7zip to unzip `ffmpeg.7z`. This file is required for YT-DLP.
### Ubuntu
1. Open your terminal application with ctrl+alt+t.
2. Run `sudo apt install ffmpeg`
<h3>Final</h3>
(Follow the next steps only if you've downloaded/cloned the source code)<br>
3. cd to project directory <br>
### Final
(Follow the next steps only if you've downloaded/cloned the source code)
3. cd to project directory in the terminal.
4. Run `python3 -m pip install -r requirements.txt`
5. Run `python3 main.py`

# How to use
1. Get a youtube or soundcloud link, or generally anything youtube-dlp supports.
1. Get a link that YT-DLP supports (YouTube, TikTok, Soundcloud, etc.).
2. Run `main.py`
3. Type in "play " and then paste in your link. (Example: `start https://youtu.be/dQw4w9WgXcQ`)
3. Choose if you want to use CLI with `--nogui` or `-ng`. You can also leave it blank to default to the GUI.
4. (1/2) CLI: Type in `[either start or play] [link or search term]`. (Example: `start https://youtu.be/dQw4w9WgXcQ`) <br>
(2/2) GUI: Enter the link or search term into the text box and press "enter."

# Media controls
`play`: Loads an audio file from either local files or a youtube link. (Aliases: `start`) <br>
`play`: Loads an audio file from either local files (not yet supported), a search term, or a supported link. (Aliases: `start`) <br>
`pause`: Pauses the current audio. <br>
`unpause`: Resume the current audio. (Aliases: `resume`, `unpause`, `continue`) <br>
`stop`: Stops playing the current soundtrack and moves on to the next one in queue. <br>
`exit`: Exits out of the media player. (Aliases: `quit`, `leave`)

# To do
1. Allow for user to select between keeping downloaded files or deleting them.
2. Check if file is already downloaded.
3. Allow for GUI usage of app.
4. Compile app in to a `.exe`
1 change: 1 addition & 0 deletions letts_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Wow. Such empty.
Binary file added letts_utils/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added letts_utils/__pycache__/queue.cpython-312.pyc
Binary file not shown.
99 changes: 99 additions & 0 deletions letts_utils/queue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
class Queue:
"""
A custom queue class for Lett's Python Utilities. \n
Please do not change any variables without their respective methods. Doing so may result in unexpected behavior and
should be avoided unless you know what you are doing.
"""
in_queue = []
left_queue = []

def __init__(self, initial_queue: list | None = None):
if initial_queue is None:
initial_queue = []

self.in_queue = initial_queue
self.left_queue = []

def __len__(self, iterable: list | dict | tuple | str):
result = len(iterable)
return result

def get_next_item(self, remove: bool = True) -> any:
"""
Gets the next item (index 0) from the queue.
:param remove: Whether to remove the value from the queue and move it to the previous values queue.
:return: Next item in the queue
"""

value = self.in_queue[0]
if not remove:
return value

self.in_queue.remove(value)
self.left_queue.append(value)
return value

def get_previous_items(self, remove: bool = True, i: int = -1) -> any:
"""
Gets the previous item (index 0) from the previous values queue.
:param remove: Whether to remove the value from the previous values queue and move it to the queue.
:param i: Amount to go back inside of the queue.
:return: Previous item in the queue
"""

value = self.left_queue[i]
if not remove:
return value

for x in range(-i):
value = self.left_queue.pop(-1)
self.in_queue.insert(0, value)

def append_to_queue(self, value) -> None:
"""
Appends to the end of the queue.
:param value: The value to append to the end of the queue.
:return: Nothing.
"""

self.in_queue.append(value)

def empty(self, debug: bool = False) -> bool:
"""
:return: If the audio queue is empty or not
"""

result = self.__len__(self.in_queue) == 0
if debug:
print(self.__len__(self.in_queue))
return result

def empty_previous(self) -> bool:
"""
:return: If the previous audio queue is empty or not
"""

return self.__len__(self.in_queue) == 0

def get_total(self) -> list:
"""
Combines both previous and current queue and returns it.
:return: Previous and currently queue combined
"""
total_queue = self.left_queue
total_queue.extend(self.in_queue)
return total_queue


if __name__ == "__main__":
# Testing initialization and getting next item without removing it.
test_queue = Queue(["Lorem", "ipsum,", "dolor", "sit", "amet"])
print(test_queue.get_next_item(False))
print(test_queue.in_queue)

# Testing getting the next item with removing it and retrieving it again from the previous queue
test_queue.get_next_item()
test_queue.get_next_item()
print(test_queue.get_previous_items(True, -2))
print(test_queue.in_queue)
print(test_queue.left_queue)
Loading