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

Preferences #2 #21

Merged
merged 17 commits into from
Oct 13, 2017
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
67 changes: 48 additions & 19 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,34 @@ def getRecapItems(videos):
for video in videos:
bitrate = int(video["name"].split("_")[1][0:-1])
height = int(video["height"])
objects.insert(0, MediaObject(
container = Container.MP4,
video_codec = VideoCodec.H264,
audio_codec = AudioCodec.AAC,
video_resolution = height,
audio_channels = 2,
height = height,
width = int(video["width"]),
parts = [
PartObject(key=Callback(PlayRecap, url=video["url"]))
]
))
if Prefs['quality'][0:3] == str(height):
objects.insert(0, MediaObject(
container = Container.MP4,
video_codec = VideoCodec.H264,
audio_codec = AudioCodec.AAC,
video_resolution = height,
audio_channels = 2,
height = height,
width = int(video["width"]),
parts = [
PartObject(key=Callback(PlayRecap, url=video["url"]))
]
))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the point of the quality setting to avoid the menu with different qualities?
To do that, we should probably just return an array with a single array item here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't see a menu with different qualities. I think I used to have that at some point, but now I don't see any way to choose the quality. Am I missing something?

else:
objects.append(MediaObject(
container = Container.MP4,
video_codec = VideoCodec.H264,
audio_codec = AudioCodec.AAC,
video_resolution = height,
audio_channels = 2,
height = height,
width = int(video["width"]),
parts = [
PartObject(key=Callback(PlayRecap, url=video["url"]))
]
))
if Prefs['quality'] == 'Auto':
objects.sort(key=lambda o: o.video_resolution, reverse=True)
return objects

return VideoClipObject(
Expand All @@ -157,7 +173,10 @@ def getStreamItems():
if STREAM_CACHE[game.game_id].get(feed.mediaId) != None:
return STREAM_CACHE[game.game_id][feed.mediaId]

cdn = 'akc'
if Prefs['cdn'] == "Level 3":
cdn = "l3c"
else:
cdn = "akc"
if game.sport == "nhl":
url = "http://mf.svc.nhl.com/m3u8/%s/%s" % (date, feed.mediaId)
else:
Expand Down Expand Up @@ -225,12 +244,19 @@ def getStreamItems():
]
)

if int(height_s) < best_height or float(fps_s) < best_fps:
objects.append(media_object)
else:
best_height = int(height_s)
best_fps = float(fps_s)
if Prefs['quality'] == 'Auto':
if int(height_s) < best_height or float(fps_s) < best_fps:
objects.append(media_object)
else:
best_height = int(height_s)
best_fps = float(fps_s)
objects.insert(0, media_object)
elif Prefs['quality'] == '720p60' and round(float(fps_s)) == 60.0:
objects.insert(0, media_object)
elif Prefs['quality'] == media_object.video_resolution+'p':
objects.insert(0, media_object)
else:
objects.append(media_object)

STREAM_CACHE[game.game_id][feed.mediaId] = objects
return objects
Expand Down Expand Up @@ -330,4 +356,7 @@ def GetMediaAuth():
salt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
garbled = ''.join(random.sample(salt, len(salt)))
auth = ''.join([garbled[int(i * random.random()) % len(garbled)] for i in range(0,241)])
return auth
return auth

def ValidatePrefs():
return None
5 changes: 4 additions & 1 deletion Contents/Code/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ class Recap(object):
def fromContent(content, content_title, sport):
def fromItem(item):
recap = Recap()
recap.title = item["title"]
if Prefs['show_scores'] or "Recap" not in item["title"]:
recap.title = item["title"]
else:
recap.title = 'Recap'
recap.summary = item["description"]
recap.year = int(item["date"][0:4])
recap.studio = sport
Expand Down
22 changes: 22 additions & 0 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"id": "show_scores",
"label": "Show scores for recaps",
"type": "bool",
"default": "true"
},
{
"id": "quality",
"type": "enum",
"label": "Quality",
"values": ["Auto", "720p60", "720p", "540p", "504p", "360p", "288p"],
"default": "Auto"
},
{
"id": "cdn",
"type": "enum",
"label": "CDN",
"values": ["Akamai", "Level 3"],
"default": "Akamai"
}
]