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

Added Generic PSSH grabber #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
27 changes: 25 additions & 2 deletions getPSSH.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
from bs4 import BeautifulSoup
import requests, xmltodict, json

def __strip_duplicates__(x):
return list(dict.fromkeys(x))

def __get_pssh_generic__(mpd_url):
page = requests.get(mpd_url)
soup = BeautifulSoup(page.text)
pssh = soup.findAll("cenc:pssh")
pssh_index = []
for item in pssh:
pssh_index.append(item.getText())
pssh_list = __strip_duplicates__(pssh_index)
#Display PSSH options
option_count = 0
for item in pssh_list:
print("Option #[" + str(option_count) + "]\n" + item + "\n\n")
option_count += 1
select = input("Select Option:")
return pssh_list[int(select)]

def get_pssh(mpd_url):
pssh = ''
try:
Expand Down Expand Up @@ -43,5 +63,8 @@ def get_pssh(mpd_url):
except Exception:
pass
if pssh == '':
pssh = input('Unable to find PSSH in mpd. Edit getPSSH.py or enter PSSH manually: ')
return pssh
try:
return __get_pssh_generic__(mpd_url)
except:
pssh = input('Unable to find PSSH in mpd. Edit getPSSH.py or enter PSSH manually: ')
return pssh