Created
May 14, 2021 18:30
-
-
Save hovedguy/8306d545e2d0fc6a8de38f4ea90e042c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import vlc | |
| import pafy | |
| import time | |
| import pygetwindow as gw | |
| urls = ["https://www.youtube.com/watch?v=w_Ma8oQLmSM", "https://www.youtube.com/watch?v=M_dZDwz9QLs"] | |
| # create and play vlc media | |
| def playVLC(url): | |
| video = pafy.new(url) | |
| best = video.getbest() # getting best stream | |
| media_player = vlc.MediaPlayer() # creating vlc media player object | |
| media = vlc.Media(best.url) # media object | |
| media_player.set_media(media) # setting media to the media player | |
| # media_player.video_set_scale(0.6) # setting video scale | |
| media_player.audio_set_volume(0) # setting volume | |
| return media_player | |
| for url in urls: | |
| mp = playVLC(url) | |
| mp.play() | |
| # re-arrange windows | |
| reqWinds = [] | |
| flag = False | |
| while not flag: | |
| temp = [] | |
| for t, w in zip(gw.getAllTitles(), gw.getAllWindows()): | |
| if 'Direct3D11 output' in t: | |
| temp.append(w) | |
| print() | |
| if len(temp) == 2: | |
| flag = True | |
| reqWinds = temp | |
| else: | |
| time.sleep(0.5) | |
| wToh = 1920 / 1080 | |
| q = len(reqWinds) | |
| h = int(870 / q) | |
| w = int(h * wToh) | |
| topLeftCoords = [(705, 0), (705, h)] | |
| for reqWind, topLeftCoord in zip(reqWinds, topLeftCoords): | |
| reqWind.resizeTo(w, h) | |
| reqWind.moveTo(topLeftCoord[0], topLeftCoord[1]) | |
| while True: | |
| time.sleep(1e6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment