Skip to content

Commit

Permalink
more updates
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 39594ee commit 29b55d2
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 127 deletions.
62 changes: 21 additions & 41 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# .github/workflows/sailfish-build.yml
name: Sailfish OS Package Build
name: Build SFOS 4.2

on:
push:
Expand All @@ -10,48 +9,29 @@ on:

jobs:
build:
runs-on: ubuntu-22.04 # Explizit Ubuntu 22.04 verwenden
container:
image: coderus/sailfishos-platform-sdk:4.4.0.58
options: --privileged
runs-on: ubuntu-latest
container: coderus/sailfishos-platform-sdk:4.2.0.21

steps:
- name: Checkout code
uses: actions/checkout@v3 # Zurück zu v3, da es stabiler mit Containern arbeitet
- uses: actions/checkout@v2

- name: Build for aarch64
run: mb2 -t SailfishOS-4.2.0.21-aarch64 build

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
fetch-depth: 0
name: rpms
path: RPMS/*.rpm

- name: Prepare build environment
shell: bash
run: |
mkdir -p ~/rpmbuild/SOURCES
mkdir -p ~/rpmbuild/SPECS
cp rpm/harbour-tidalplayer.spec ~/rpmbuild/SPECS/
cp rpm/harbour-tidalplayer.yaml ~/rpmbuild/SPECS/
- name: Create source tarball
shell: bash
run: |
VERSION=$(grep "Version:" rpm/harbour-tidalplayer.yaml | cut -d':' -f2 | tr -d ' ')
tar --transform "s,^,harbour-tidalplayer-$VERSION/," -czf ~/rpmbuild/SOURCES/harbour-tidalplayer-$VERSION.tar.gz *
- name: Build RPM package
shell: bash
run: |
cd ~/rpmbuild/SPECS
mb2 -t SailfishOS-4.4.0.58 -s harbour-tidalplayer.spec build
- name: Upload RPM artifacts
uses: actions/upload-artifact@v3 # Verwende v3 für bessere Container-Kompatibilität
with:
name: harbour-tidalplayer-rpm
path: ~/rpmbuild/RPMS/**/*.rpm
if-no-files-found: error

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
- name: Create/Update Release
uses: softprops/action-gh-release@v1
with:
files: ~/rpmbuild/RPMS/**/*.rpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag_name: nightly
name: Nightly Build
files: RPMS/*.rpm
prerelease: true
body: Automated nightly build
token: ${{ secrets.GITHUB_TOKEN }}
replace_artifacts: true

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@ As v0.7.1 is not fully compatible with TIDAL anymore, the line 114 of tidalapi/u

### Usage of AI
The current development is driven by Claude 3.5 Sonnet. The icon is made by Midjourney.

## Future Features

- Tidal account integration with OAuth authentication
- Browse and search Tidal's music library
- Create and manage playlists
- Play tracks, albums, and playlists
- Media controls (play, pause, next, previous)
- Track information display
- Album artwork display

## Requirements

- Python 3.x
- Qt/QML
- PyOtherSide
- Tidal API credentials

26 changes: 21 additions & 5 deletions qml/components/AuthManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import QtQuick 2.0
import Nemo.Configuration 1.0

Item {
id: root
id: authManager

// Properties
property bool isLoggedIn: false
Expand Down Expand Up @@ -31,16 +31,32 @@ Item {
key: "/expiry_time"
}

ConfigurationValue {
id: mail
key: "/mail"
}

ConfigurationValue {
id: audioQuality
key: "/audioQuality"
defaultValue: "HIGH" // Standardwert
}

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

var currentUnixTime = Math.floor(new Date().getTime() / 1000)
var oneWeekLater = currentUnixTime + 604800

token_type.value = type
access_token.value = token
refresh_token.value = rtoken
expiry_time.value = expiry
expiry_time.value = oneWeekLater
isLoggedIn = true
}

function checkAndLogin() {
pythonApi.quality = audioQuality.value
if (token_type.value && access_token.value) {
if (isTokenValid()) {
console.log("old token valid");
Expand All @@ -60,10 +76,10 @@ Item {
}

function isTokenValid() {

var currentUnixTime = Math.floor(new Date().getTime() / 1000)
if (!expiry_time.value) return false
return Date.fromLocaleString(Qt.locale(),
expiry_time.value,
"yyyy-MM-ddThh:mm:ss") > currentDate
return expiry_time.value > currentUnixTime
}

function clearTokens() {
Expand Down
15 changes: 13 additions & 2 deletions qml/components/TidalApi.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ Item {
property string playlist_artist: ""
property string playlist_album: ""
property string playlist_image: ""

property string quality: ""


property int playlist_duration: 0
property int playlist_track_id: 0

property AuthManager authManager
Python {
id: pythonTidal

Expand All @@ -67,6 +72,8 @@ Item {
pythonApi.loginFailed()
})
setHandler('get_token', function(type, token, rtoken, date) {
console.log("Got new token from session")
console.log(type, token, rtoken, date)
pythonApi.oAuthSuccess(type, token, rtoken, date)
})

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

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

onLoginSuccess: {
Expand All @@ -175,8 +184,10 @@ Item {

function loginIn(tokenType, accessToken, refreshToken, expiryTime) {
console.log(accessToken)
pythonTidal.call('tidal.Tidaler.initialize', [quality])
pythonTidal.call('tidal.Tidaler.login',
[tokenType, accessToken, refreshToken, expiryTime])
//pythonTidal.call('tidal.Tidaler.checkAndLogin', [])
}

// Search Funktionen
Expand Down
85 changes: 48 additions & 37 deletions qml/dialogs/OAuth.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

import io.thp.pyotherside 1.5
import Sailfish.WebView 1.0
import Sailfish.WebEngine 1.0
Expand All @@ -12,51 +11,63 @@ Dialog {
allowedOrientations: Orientation.All
canAccept: false

ConfigurationValue {
id: mail
key: "/mail"
}

WebView {
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
id: webView
anchors.fill: parent

id: webView
url: "http://www.sailfishos.org"
httpUserAgent: "Mozilla/5.0 (Mobile; rv:78.0) Gecko/78.0 Firefox/78.0"

anchors.fill: parent
popupProvider: PopupProvider { }

url: "http://www.sailfishos.org"
//privateMode: true
httpUserAgent: "Mozilla/5.0 (Mobile; rv:78.0) Gecko/78.0"
+ " Firefox/78.0"
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);";

popupProvider: PopupProvider {
// Disable the Save Password dialog
//passwordManagerPopup: null
}
}

Connections {
target: pythonApi
onAuthUrl:
{
console.log(url)
webView.load("https://" + url)
webView.runJavaScript(script);
}
}
}

onLoginSuccess:
{
accountSettings.canAccept = true
accountSettings.accept()
loginTrue = true
Connections {
target: pythonApi
onAuthUrl: {
console.log(url)
webView.url = "https://" + url
}

pythonApi.logIn()
}
onLoginSuccess: {
accountSettings.canAccept = true
accountSettings.accept()
loginTrue = true
authManager.checkAndLogin()
}

onLoginFailed:
{
mainLabel.text = "Failed";
loginTrue = false
}
onLoginFailed: {
mainLabel.text = "Failed"
loginTrue = false
}
}

Component.onCompleted: {
pythonApi.getOAuth()
}
Component.onCompleted: {
pythonApi.getOAuth()
}
}

4 changes: 2 additions & 2 deletions qml/harbour-tidalplayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ ApplicationWindow
authManager.checkAndLogin()
mprisPlayer.setCanControl(true)
}
/*

Connections {
target: pythonApi
onOAuthSuccess: {
Expand All @@ -171,7 +171,7 @@ ApplicationWindow
authManager.clearTokens()
}
}
*/


Connections
{
Expand Down
5 changes: 4 additions & 1 deletion qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ Page {
PullDownMenu {
MenuItem {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("Settings.qml"))
onClicked: {
minPlayerPanel.open = false
pageStack.push(Qt.resolvedUrl("Settings.qml"))
}
}


Expand Down
Loading

0 comments on commit 29b55d2

Please sign in to comment.