Skip to content

Support for new tv4play #175

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

Merged
merged 2 commits into from
Jul 3, 2023
Merged

Support for new tv4play #175

merged 2 commits into from
Jul 3, 2023

Conversation

viktorlindgren
Copy link
Contributor

Fixes #172

New cookies permission is required for www.tv4play.se in order to extract the tv4-refresh-token key.

Copy link
Owner

@stefansundin stefansundin left a comment

Choose a reason for hiding this comment

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

Tack så mycket för hjälpen! :)

Det är några saker som måste ändras men jag kan göra det själv om det går bra. Har skrivit några kommentarer med förklaringar.

Comment on lines 55 to 56
var filter = { domain: "www.tv4play.se", name: "tv4-refresh-token" };
chrome.cookies.getAll(filter, function (cookies) {
Copy link
Owner

Choose a reason for hiding this comment

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

Istället för att hämta cookien med chrome.cookies så kan vi använda chrome.tabs.executeScript. Då slipper vi be om nya behörigheter.

    chrome.tabs.executeScript({
      code: `document.cookie.split(';').map(c => c.trim()).find(c => c.startsWith("tv4-refresh-token="))?.split("=")[1]`
    }, function(refreshToken) {
      console.log('refreshToken', refreshToken);
    });

// https://www.tv4.se/klipp/va/3349622/namen-har-sover-peter-dalle-under-tommy-korbergs-framtradande
// https://www.tv4play.se/video/35e58882dbdd430da786/cornelia-jakobs
Copy link
Owner

Choose a reason for hiding this comment

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

Det verkar som att gamla URL på tv4.se fortfarande fungerar, som den här till exempel. Så jag kommer nog bevara den gamla koden också så att de fortsätter att fungera.

Det verkar som att nya tv4.se program är lite krångligare. Exempel: https://www.tv4.se/artikel/4oYvgW4JjW7euNnluO7peA/bloet-start-pa-juli-sa-laenge-fortsaetter-regnet-kraftiga-askskurar

Här måste vi hitta en video id (20622424), som kan hittas i några olika ställen, t.ex. i __NEXT_DATA__ (görs redan i ur.js). Tror att jag skippar detta tills senare.

Comment on lines 23 to 24
"cookies",
"https://www.tv4play.se"
Copy link
Owner

Choose a reason for hiding this comment

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

Om vi hade behövt dessa så skulle vi stoppa dem i optional_permissions och sedan be användaren att acceptera dem när de försöker använda tillägget på TV4. Detta är enkelt, exempel:

permissions: {
origins: ["https://psapi.nrk.no/"],
},

…ie and keep the old code around for old tv4.se URLs.
@stefansundin stefansundin merged commit 4998a59 into stefansundin:master Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TV4Play funkar inte
2 participants