Skip to content

Commit

Permalink
Video quality removed from Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankokan committed Oct 7, 2019
1 parent 4b3b121 commit acdca8a
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 87 deletions.
4 changes: 0 additions & 4 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ msgctxt "#50002"
msgid "Password"
msgstr ""

msgctxt "#50003"
msgid "Video quality"
msgstr ""

msgctxt "#50004"
msgid "Show scores"
msgstr ""
Expand Down
4 changes: 0 additions & 4 deletions resources/language/Hebrew/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ msgctxt "#50002"
msgid "Password"
msgstr "סיסמה"

msgctxt "#50003"
msgid "Video quality"
msgstr "איכות וידאו מיו-טיוב"

msgctxt "#50004"
msgid "Show scores"
msgstr "הצג ניקוד"
Expand Down
1 change: 0 additions & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<setting id="username" type="text" label="50001" default="" />
<setting id="password" type="text" label="50002" option="hidden" default="" />
<setting type="sep" />
<setting id="quality_id" type="enum" label="50003" values="Auto|1080p|720HD|720p|540p|360p|240p" default="1" />
<setting id="scores" type="bool" label="50004" default="false" />
<setting id="local_timezone" type="bool" label="50007" default="true" />
<setting id="fav_team" type="select" label="50009" values="None|Hawks|Celtics|Nets|Hornets|Bulls|Cavaliers|Mavericks|Nuggets|Pistons|Warriors|Rockets|Pacers|Clippers|Lakers|Grizzlies|Heat|Bucks|Timberwolves|Pelicans|Knicks|Thunder|Magic|76ers|Suns|Trail Blazers|Kings|Spurs|Raptors|Jazz|Wizards" default="None" />
Expand Down
53 changes: 0 additions & 53 deletions src/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,6 @@ def updateFavTeam():
def getGameUrlWithBitrate(url, video_type):
return url

def getGameUrlWithBitrate_Old(url, video_type):
if vars.target_video_height == -1:
return "%s|User-Agent=%s" % (url, vars.useragent)

# Force the bitrate by modifying the HLS url and adding the bitrate
available_bitrates = [
(72060, 6000),
(720, 3000),
(540, 1600),
(432, 1200),
(360, 800),
]

#"video" video_type starts from 3000k as bitrate
if video_type == "video":
available_bitrates.pop(0)

#Get the chosen bitrate, and all the bitrates after that one
target_bitrates = [item[1] for item in available_bitrates if item[0] <= vars.target_video_height]
log('target_bitrates: %s' % target_bitrates, xbmc.LOGDEBUG)

regex_pattern = 'whole_([0-9])_ipad'
regex_replacement_format = r'whole_\1_%s_ipad'
if video_type == "condensed":
regex_pattern = 'condensed_([0-9])_ipad'
regex_replacement_format = r'condensed_\1_%s_ipad'
elif video_type == "live":
regex_pattern = '([a-z]+)_hd_ipad'
regex_replacement_format = r'\1_hd_%s_ipad'
elif video_type == "video":
regex_pattern = '1_([0-9]+)\.mp4'
regex_replacement_format = r'1_%s.mp4'

#Try the target bitrate, and if it doesn't exists, try every bitrate lower than the chosen one
#(eg: if you chouse 3000k as bitrate, it will try 3000k, then 1600k, then 1200k,
#and so on)
selected_video_url = ""
for target_bitrate in target_bitrates:
selected_video_url = re.sub(regex_pattern, regex_replacement_format % target_bitrate, url)

#The "video" url is rtmp:// so i can't test it with urlopen().getcode(),
#so break on first iteration of the loop
if video_type == "video":
break

#If video is found, break
if urllib.urlopen(selected_video_url).getcode() == 200:
break

log("video of bitrate %d not found, trying with next height" % target_bitrate, xbmc.LOGDEBUG)

return "%s|User-Agent=%s" % (selected_video_url, vars.useragent)

def getFanartImage():
# get the feed url
feed_url = "http://smb.cdnak.neulion.com/fs/nba/feeds/common/dl.js"
Expand Down
7 changes: 2 additions & 5 deletions src/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,13 @@ def getGameUrl(video_id, video_type, video_ishomefeed, start_time, duration):
utils.log("live cookie: %s %s" % (querystring, livecookies), xbmc.LOGDEBUG)

url = "%s://%s/%s?%s" % (protocol, domain, arguments, querystring)
url = common.getGameUrlWithBitrate_Old(url, video_type)
url = common.getGameUrlWithBitrate(url, video_type)

selected_video_url = "%s&Cookie=%s" % (url, livecookiesencoded)
else:
# Archive and condensed flow: We now work with HLS.
# The cookies are already in the URL and the server will supply them to ffmpeg later.
if '.mpd' in url:
selected_video_url = common.getGameUrlWithBitrate(url, video_type)
else:
selected_video_url = common.getGameUrlWithBitrate_Old(url, video_type)
selected_video_url = common.getGameUrlWithBitrate(url, video_type)

if selected_video_url:
utils.log("the url of video %s is %s" % (video_id, selected_video_url), xbmc.LOGDEBUG)
Expand Down
4 changes: 0 additions & 4 deletions src/leaguepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
from favteam import *
import vars

utils.log("Chosen quality_id: %d" % vars.quality_id)
utils.log("...mapped to target_bitrate: %d (mpd)" % vars.target_bitrate)
utils.log("...mapped to target_video_height: %d (old)" % vars.target_video_height)

def mainMenu():
if isLiveUsable():
addListItem('Live games', 'live', 'live','', True)
Expand Down
2 changes: 1 addition & 1 deletion src/nbatvlive.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def getLiveUrl(force_login=False):
for streamdata in streamdata_list:
video_height = streamdata.getElementsByTagName("video")[0].attributes["height"].value

if int(video_height) == vars.target_video_height:
if int(video_height) == vars.target_video_height: # TODO
selected_video_path = streamdata.attributes["url"].value
http_servers = streamdata.getElementsByTagName("httpserver")

Expand Down
14 changes: 0 additions & 14 deletions src/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,9 @@
show_cameras = json.loads(settings.getSetting(id="cameras"))
useragent = "iTunes-AppleTV/4.1"

# Map the quality_id to a bitrate (mpd) or a video height (old)
quality_id = int(settings.getSetting(id="quality_id"))
bitrates_per_quality = [-1, 10000, 4500, 3000, 1600, 800, 400]
video_heights_per_quality = [-1, 72060, 72060, 720, 540, 360, 360]
target_bitrate = bitrates_per_quality[quality_id]
target_video_height = video_heights_per_quality[quality_id]

cache = StorageServer.StorageServer("nbaleaguepass", 1)
cache.table_name = "nbaleaguepass"

# Delete the video urls cached if the video quality setting has changed
if cache.get("target_bitrate") != str(target_bitrate) or cache.get("target_video_height") != str(target_video_height):
cache.delete("video_%")
cache.set("target_bitrate", str(target_bitrate))
cache.set("target_video_height", str(target_video_height))
print "deleting video url cache"

cookies = ''
player_id = binascii.b2a_hex(os.urandom(16))
addon_dir = xbmc.translatePath( settings.getAddonInfo('path') ).decode('utf-8')
Expand Down
2 changes: 1 addition & 1 deletion src/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def videoPlay():

xml = parseString(str(content))
video_url = xml.getElementsByTagName("path")[0].childNodes[0].nodeValue
video_url = getGameUrlWithBitrate_Old(video_url, "video")
video_url = getGameUrlWithBitrate(video_url, "video")
log("videoPlay: video url is %s" % video_url, xbmc.LOGDEBUG)

#remove query string
Expand Down

0 comments on commit acdca8a

Please sign in to comment.