Skip to content

Commit

Permalink
made a version work on test pinetab2
Browse files Browse the repository at this point in the history
Signed-off-by: Conrad Hübler <Conrad.Huebler@gmx.net>
  • Loading branch information
conradhuebler committed Dec 27, 2024
1 parent ccf71c7 commit 03b565f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion qml/components/AuthManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Item {

// Funktionen zum Token-Management
function updateTokens(type, token, rtoken, expiry) {

console.log("Update tokes")
var currentUnixTime = Math.floor(new Date().getTime() / 1000)
var oneWeekLater = currentUnixTime + 604800

Expand Down
13 changes: 7 additions & 6 deletions qml/components/TidalApi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Item {
property bool tracks: true
property bool playlists: true

property bool loginTrue: false

property string playlist_track: ""
property string playlist_artist: ""
property string playlist_album: ""
Expand All @@ -51,7 +53,6 @@ Item {
property int playlist_duration: 0
property int playlist_track_id: 0

property AuthManager authManager
Python {
id: pythonTidal

Expand Down Expand Up @@ -158,11 +159,9 @@ Item {
}

onOAuthSuccess: {
console.log(type, token, rtoken, date)
//if (authManager) {
authManager.updateTokens(type, token, rtoken, date)
loginSuccess()
//}
console.log(type, token, rtoken, date)
authManager.updateTokens(type, token, rtoken, date)
loginSuccess()
}

onLoginSuccess: {
Expand All @@ -179,6 +178,8 @@ Item {

// Login Funktionen
function getOAuth() {
console.log("Request new login")
pythonTidal.call('tidal.Tidaler.initialize', [quality])
pythonTidal.call('tidal.Tidaler.request_oauth', [])
}

Expand Down
20 changes: 3 additions & 17 deletions qml/dialogs/OAuth.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Dialog {
key: "/mail"
}


WebView {
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
Expand All @@ -27,30 +28,15 @@ Dialog {

popupProvider: PopupProvider { }

onLoadingChanged: {
if (loadRequest.status === WebView.LoadSucceededStatus) {
var script = "function fillEmail() {" +
"var emailInput = document.querySelector('input[type=\"email\"]') || " +
"document.querySelector('input[name=\"email\"]') || " +
"document.querySelector('#email');" +
"if (emailInput) {" +
" emailInput.value = '" + mail.value + "';" +
" emailInput.dispatchEvent(new Event('input'));" +
" emailInput.dispatchEvent(new Event('change'));" +
"}" +
"};" +
"fillEmail();" +
"setTimeout(fillEmail, 500);";

webView.runJavaScript(script);
}
}

}

Connections {
target: pythonApi
onAuthUrl: {
console.log(url)
Clipboard.text = mail.value
webView.url = "https://" + url
}

Expand Down
7 changes: 6 additions & 1 deletion qml/pages/Personal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Item {
}

Component.onCompleted: {
pythonApi.getPersonalPlaylists()
if(pythonApi.loginTrue) pythonApi.getPersonalPlaylists()
}

Connections
Expand All @@ -99,5 +99,10 @@ Item {

})
}

onLoginSuccess:
{
pythonApi.getPersonalPlaylists()
}
}
}
4 changes: 2 additions & 2 deletions qml/pages/Search.qml
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ Item {
onLoginSuccess:
{
searchString.label = "Find"
searchString.enabled = loginTrue
searchString.enabled = pythonApi.loginTrue
}
onLoginFailed:
{
searchString.label = "Please go to the settings and login via OAuth"
searchString.enabled = loginTrue
searchString.enabled = pythonApi.loginTrue
}
}

Expand Down
2 changes: 1 addition & 1 deletion qml/pages/TrackList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ SilicaListView {

visible: listModel.get(model.index).type === 1
x: Theme.horizontalPageMargin
truncationMode: Fade
//truncationMode: Fade
font.pixelSize: Theme.fontSizeSmall
}
}
Expand Down
4 changes: 2 additions & 2 deletions qml/pages/widgets/MiniPlayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ DockedPanel {
IconButton {
id: prevButton
icon.source: "image://theme/icon-m-previous"
visible: playlistManager.canPrev
//visible: playlistManager.canPrev
onClicked: playlistManager.previousTrackClicked()
}

Expand All @@ -121,7 +121,7 @@ DockedPanel {
IconButton {
id: nextButton
icon.source: "image://theme/icon-m-next"
visible: playlistManager.canNext
//visible: playlistManager.canNext
onClicked: {
mediaPlayer.blockAutoNext = true
playlistManager.nextTrackClicked()
Expand Down
2 changes: 2 additions & 0 deletions qml/tidal.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self):
self.config = None

def initialize(self, quality="HIGH"):
pyotherside.send("printConsole", "Initialise tidal api")

if quality == "LOW":
selected_quality = tidalapi.Quality.low
elif quality == "HIGH":
Expand Down

0 comments on commit 03b565f

Please sign in to comment.