Skip to content

Commit

Permalink
Reenabled HTTPS, disabling had no effect on #2. Plus minor enhancemen…
Browse files Browse the repository at this point in the history
…ts and refactoring
  • Loading branch information
hillt03 committed Dec 18, 2019
1 parent 0137297 commit 4411b40
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ colorama==0.4.3
pafy==0.5.5
python-vlc==3.0.7110
youtube-dl==2019.11.28
VLCYT==1.3
VLCYT==1.5
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="VLCYT",
version="1.3", # update VLCYT version in requirements as well
version="1.5", # update VLCYT version in requirements as well
description="Stream your YouTube playlist in VLC behind the scenes from the command line.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
24 changes: 14 additions & 10 deletions vlcyt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ def __init__(self, playlist_url, song_info_enabled=True):
self.back_song = False # Becomes True if the user enters the back command
self.back_amount = 1 # Stores how many indexes back will be popped from song_history to get songs in history


def play_playlist_songs(self):
"""
Play every song in the passed in playlist.
"""
while True:
if (
not self.loop_song
and not self.shuffle_playlist
and not self.back_song
and not self.skip_song
): # No extra features enabled. Default.
if not self._input_features_enabled(): # No extra features enabled. Default.
self._get_next_song()
elif self.skip_song: # Song(s) skipped
self.skip_song = False
Expand Down Expand Up @@ -116,7 +112,7 @@ def _get_next_song_shuffling(self):
self._set_current_song(self.song_index)
self._add_song_to_history()

def _print_current_song_information(self):
def _print_current_song_information(self, print_command_string=True):
"""
Prints the current song's relevant information.
"""
Expand All @@ -130,7 +126,7 @@ def _print_current_song_information(self):
{Fore.GREEN}Views:{Fore.RESET} {self.current_song.viewcount:,d}
{Fore.GREEN}Rating:{Fore.RESET} {round(self.current_song.rating, 2)}
{Fore.CYAN}======================================
{self.command_string}""",
{self.command_string if print_command_string else ""}""",
end="",
)

Expand All @@ -141,13 +137,17 @@ def _play_current_song(self):

self._reset_state()
# Play song
song_url = self.current_song.getbestaudio().url
song_url = self.current_song.getbestaudio().url_https
self.vlc_player.set_mrl(song_url, ":no-video")
self.vlc_player.play()

if not self.input_thread_started:
self._print_current_song_information(print_command_string=False)
print(f"{Fore.YELLOW}===Enter ? to view a list of commands==={Fore.RESET}")
self.cmds.input_thread.start()
self.input_thread_started = True
self._print_current_song_information()
else:
self._print_current_song_information()

# Sleep for duration of song
self._song_timer()
Expand Down Expand Up @@ -179,6 +179,10 @@ def _reset_state(self):
return True
return False

def _input_features_enabled(self):
input_features = [self.loop_song, self.shuffle_playlist, self.back_song, self.skip_song]
return True if True in input_features else False

def _add_song_to_history(self):
"""
Adds the current song index to song_history.
Expand Down
1 change: 0 additions & 1 deletion vlcyt/command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def _get_input(self):
"""
Gathers user input from the input thread and executes commands.
"""
print("===Enter ? to view a list of commands===")
while True:
command_name, command_value = self._get_command()
if command_name in self._help_commands:
Expand Down

0 comments on commit 4411b40

Please sign in to comment.