Skip to content

Commit

Permalink
Rework profile selection
Browse files Browse the repository at this point in the history
  • Loading branch information
shirt-dev committed Oct 9, 2022
1 parent a4bc5f9 commit 0c6844c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 68 deletions.
125 changes: 58 additions & 67 deletions cadmium-playercore-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,86 +39,77 @@ request.send();
var cadmium_src = request.responseText;

// eslint-disable-next-line no-unused-vars
function get_profile_list() {
function get_profile_list(original_profiles) {
var profiles = original_profiles;
// Always add h264 main profiles
var custom_profiles = [
"playready-h264mpl30-dash",
"playready-h264mpl31-dash",
"playready-h264mpl40-dash",
];

if (window.MSMediaKeys) {
// PlayReady Specific

// Always add 2.0 AAC profiles, some manifests fail without them
custom_profiles = custom_profiles.concat([
"heaac-2-dash",
"heaac-2hq-dash",
if (original_profiles.includes("playready-h264mpl30-dash")) {
profiles = profiles.concat([
"playready-h264mpl30-dash",
"playready-h264mpl31-dash",
"playready-h264mpl40-dash",
]);
}

if (globalOptions.useDDPlus) {
// Dolby Digital
custom_profiles = custom_profiles.concat([
"ddplus-2.0-dash",
]);

if (globalOptions.use6Channels) {
custom_profiles = custom_profiles.concat([
"ddplus-5.1-dash",
"ddplus-5.1hq-dash",
"ddplus-atmos-dash",
]);
}
} else {
// No Dolby Digital
if (globalOptions.use6Channels) {
custom_profiles = custom_profiles.concat([
"heaac-5.1-dash",
]);
}
}


} else {
// Widevine Specific
custom_profiles = custom_profiles.concat([
if (original_profiles.includes("playready-h264hpl30-dash")) {
profiles = profiles.concat([
"playready-h264hpl30-dash",
"playready-h264hpl31-dash",
"playready-h264hpl40-dash",
]);
}

if (!globalOptions.disableVP9) {
// Add VP9 Profiles if wanted
custom_profiles = custom_profiles.concat([
"vp9-profile0-L30-dash-cenc",
"vp9-profile0-L31-dash-cenc",
"vp9-profile0-L40-dash-cenc",
]);
}
if (original_profiles.includes("h264hpl30-dash-playready-live")) {
profiles = profiles.concat([
"h264hpl30-dash-playready-live",
"h264hpl31-dash-playready-live",
"h264hpl40-dash-playready-live",
]);
}

custom_profiles = custom_profiles.concat([
"heaac-2-dash",
"heaac-2hq-dash",
if (!globalOptions.disableVP9 && original_profiles.includes("vp9-profile0-L30-dash-cenc")) {
profiles = profiles.concat([
"vp9-profile0-L30-dash-cenc",
"vp9-profile0-L31-dash-cenc",
"vp9-profile0-L40-dash-cenc",
]);
} else {
profiles = profiles.filter(val => !val.includes("vp9-"));
}

if (!globalOptions.disableAV1 && original_profiles.includes("av1-main-L30-dash-cbcs-prk")) {
profiles = profiles.concat([
"av1-main-L30-dash-cbcs-prk",
"av1-main-L31-dash-cbcs-prk",
"av1-main-L40-dash-cbcs-prk",
]);
} else {
profiles = profiles.filter(val => !val.includes("av1-"));
}

if (globalOptions.useDDPlus && MediaSource.isTypeSupported('audio/mp4; codecs="ec-3"')) {
// Dolby Digital
profiles = profiles.concat([
"ddplus-2.0-dash",
]);

if (globalOptions.use6Channels) {
profiles = profiles.concat([
"ddplus-5.1-dash",
"ddplus-5.1hq-dash",
"ddplus-atmos-dash",
]);
}
} else {
// No Dolby Digital
if (globalOptions.use6Channels) {
custom_profiles = custom_profiles.concat([
profiles = profiles.concat([
"heaac-5.1-dash",
]);
}
}

// Always add subtitles
custom_profiles = custom_profiles.concat([
"dfxp-ls-sdh",
"simplesdh",
"nflx-cmisc",
"imsc1.1",
"BIF240",
"BIF320",
]);

return custom_profiles;
profiles = [...new Set(profiles)].sort();
return profiles;
}

// eslint-disable-next-line no-unused-vars
Expand All @@ -139,14 +130,14 @@ do_patch(

do_patch(
"Custom profiles",
/(viewableId:.,profiles:).,/,
"$1 get_profile_list(),"
/(viewableId:.,profiles:)(.),/,
"$1 get_profile_list($2),"
);

do_patch(
"Custom profiles 2",
/(name:"default",profiles:).}/,
"$1 get_profile_list()}"
/(name:"default",profiles:)(.)}/,
"$1 get_profile_list($2)}"
);

do_patch(
Expand Down
1 change: 1 addition & 0 deletions content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ chromeStorageGet({
showAllTracks: true,
setMaxBitrate: false,
disableVP9: false,
disableAV1: true,
useDDPlus: false,
preferredLocale: null,
preferredTextLocale: null,
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Netflix International",
"description": "Displays all available Netflix audio and subtitle tracks.",
"version": "2.0.15",
"version": "2.0.16",
"author": "shirt",
"browser_action": {
"default_icon": "img/icon128.png",
Expand Down
2 changes: 2 additions & 0 deletions pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<br>
<input type="checkbox" id="disableVP9"><label for="disableVP9">Disable VP9 codec (Chrome/Firefox)</label>
<br>
<input type="checkbox" id="disableAV1"><label for="disableAV1">Disable AV1 codec (Chrome/Firefox)</label>
<br>
<input type="checkbox" id="useDDPlus"><label for="useDDPlus">Use Dolby Digital Plus (Chromium Edge)</label>
<br>
<label for="preferredLocale">Preferred audio language</label>
Expand Down
6 changes: 6 additions & 0 deletions pages/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function save_options() {
const showAllTracks = document.getElementById("showAllTracks").checked;
const setMaxBitrate = document.getElementById("setMaxBitrate").checked;
const disableVP9 = document.getElementById("disableVP9").checked;
const disableAV1 = document.getElementById("disableAV1").checked;
const useDDPlus = document.getElementById("useDDPlus").checked;
const preferredLocale = document.getElementById("preferredLocale").value;
const preferredTextLocale = document.getElementById("preferredTextLocale").value;
Expand All @@ -13,6 +14,7 @@ function save_options() {
showAllTracks: showAllTracks,
setMaxBitrate: setMaxBitrate,
disableVP9: disableVP9,
disableAV1: disableAV1,
useDDPlus: useDDPlus,
preferredLocale: preferredLocale,
preferredTextLocale: preferredTextLocale,
Expand All @@ -30,6 +32,7 @@ function reset_options() {
document.getElementById("showAllTracks").checked = true;
document.getElementById("setMaxBitrate").checked = false;
document.getElementById("disableVP9").checked = false;
document.getElementById("disableAV1").checked = true;
document.getElementById("useDDPlus").checked = false;
document.getElementById("preferredLocale").value = null;
document.getElementById("preferredTextLocale").value = null;
Expand All @@ -39,6 +42,7 @@ function reset_options() {
showAllTracks: true,
setMaxBitrate: false,
disableVP9: false,
disableAV1: true,
useDDPlus: false,
preferredLocale: null,
preferredTextLocale: null,
Expand All @@ -57,6 +61,7 @@ function restore_options() {
showAllTracks: true,
setMaxBitrate: false,
disableVP9: false,
disableAV1: true,
useDDPlus: false,
preferredLocale: null,
preferredTextLocale: null,
Expand All @@ -65,6 +70,7 @@ function restore_options() {
document.getElementById("showAllTracks").checked = items.showAllTracks;
document.getElementById("setMaxBitrate").checked = items.setMaxBitrate;
document.getElementById("disableVP9").checked = items.disableVP9;
document.getElementById("disableAV1").checked = items.disableAV1;
document.getElementById("useDDPlus").checked = items.useDDPlus;
document.getElementById("preferredLocale").value = items.preferredLocale;
document.getElementById("preferredTextLocale").value = items.preferredTextLocale;
Expand Down

0 comments on commit 0c6844c

Please sign in to comment.