Dateien nach "/" hochladen

This commit is contained in:
2026-07-30 13:21:47 +00:00
commit 3e8975cc9c
3 changed files with 250 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2024, Skye [RE.DFINED]
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+111
View File
@@ -0,0 +1,111 @@
> [!TIP]
> There is a Chrome plugin now! https://chromewebstore.google.com/detail/y99-bio-updater/hgfccbmbbifbfdilnilmapfpaffjbojn?hl=de&authuser=0
# RE.DFINED Y99 BIO
> [!CAUTION]
> THIS APP USES THE SESSION TOKEN! NEVER GIVE THIS TO ANYONE!
## Introduction
<img src="https://cloud.re.dfined.net/apps/files_sharing/publicpreview/k6sCc87WjRDbkHM?file=/&fileId=2041&x=1924&y=924&a=true&etag=25010b217b1059db37a0f3aa37026641" align="center" width="50%">
RE.DFINED Y99 BIO is a Python application designed to automatically update your Y99 bio with the current song you're listening to. By integrating with YouTube and Last.fm APIs, this app fetches the song information and updates your bio accordingly. This README provides a comprehensive guide to set up and configure the app.
![Screenshot](https://cloud.skye.li/apps/files_sharing/publicpreview/b9BEF2Jxy6GEzFt?file=/&fileId=7633&x=3456&y=2234&a=true&etag=95f655788d1b951f9d990a692663c4f7)
## Prerequisites
Before you start, ensure you have the following:
- Python 3.6 or higher
- pip (Python package installer)
- Access to Last.fm API
- A Last.fm account connected to your music service of choice. [Last.fm Help](https://www.last.fm/about/trackmymusic)
## Install Instructions
### On Windows
1. **Install Python:**
- Download the Python 3. from the Microsoft Store.
2. **Install pip:**
- Pip is included by default with Python installations. You can verify it by running `pip --version` in Command Prompt.
3. **Install required modules:**
- Open Command Prompt and run:
```bash
pip install flask requests aiotube
```
### On Linux
1. **Install Python:**
- Use your package manager to install Python. For Debian-based systems (like Ubuntu), run:
```bash
sudo apt update
sudo apt install python3 python3-pip
```
2. **Install required modules:**
- Open a terminal and run:
```bash
pip3 install flask requests aiotube
```
## Getting API Keys for Last.fm
**Last.fm API:**
- Visit the [Last.fm API page](https://www.last.fm/api/).
- Sign up for a Last.fm account if you don't have one.
- Go to the "Create an API Account" section.
- Follow the instructions to obtain your API Key.
## Filling the API Keys into `app.py`
Open the `app.py` file and locate the following lines:
```python
# API-Daten
api_key = 'LAST_FM_API_HERE'
```
# API-DATA
api_key = 'LAST_FM_API_HERE'
Replace `'LAST_FM_API_HERE'` with your Last.fm API Key.
## Getting the Session Token
1. Open the Y99 web application and press `F12` to open Developer Tools.
2. Navigate to the "Network" tab.
3. Look for a request with the name "whatsup".
4. Click on this request and go to the "Payload" tab.
5. Find the `auth` field in the payload section. The `session-token` value is what you need.
Copy this session token and ensure it is used in your application as required.
I will realease my Beta Plugin to Extract the token quickly later on.
## Usage
> [!WARNING]
> BACKUP YOUR BIO BEFOREHAND!
1. **Run the App:**
- Open the folder in witch the app.py file is located (on windows just type cmd in the navigation bar of the folder)
- Execute the following command in your terminal or command prompt:
```bash
python app.py
```
2. **Web UI:**
- Open your Webbrowser on http://localhost:5000 or if you host it on a server http://server-ip:5000
3. **Monitor:**
- The app will fetch the current song from Last.fm and update your Y99 bio accordingly.
## Troubleshooting
- **API Errors:** Ensure that your API keys are correctly configured and have the necessary permissions.
- **Network Issues:** Verify your internet connection and check the network settings.
Have fun with your cool new Bio
## Support
[Y99 Support room](https://y99.in/r/1808532)
+111
View File
@@ -0,0 +1,111 @@
from flask import Flask, render_template, request, redirect, url_for
import requests
import time
import threading
import urllib.parse
from aiotube import Search
app = Flask(__name__)
app.secret_key = 'your_secret_key'
# API Key
api_key = 'YOUR_LAST_FM_API_KEY' #Enter yoour last.fm API key here.
# Global variable to track the monitoring status
monitoring_active = {}
# Initialize aiotube search instance
search = Search()
def get_current_song(api_key, username):
url = f'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user={username}&api_key={api_key}&format=json&limit=1'
response = requests.get(url)
data = response.json()
if 'recenttracks' in data and len(data['recenttracks']['track']) > 0:
track = data['recenttracks']['track'][0]
song_name = track['name']
artist_name = track['artist']['#text']
return song_name, artist_name
return None, None
def get_youtube_link(song_name, artist_name):
search_query = f'{song_name} {artist_name}'
encoded_query = urllib.parse.quote(search_query) # URL-encode the search query
try:
# Search for videos using aiotube
results = search.videos(encoded_query, limit=1)
if results and len(results) > 0:
video_id = results[0]
youtube_link = f'https://www.youtube.com/watch?v={video_id}'
return youtube_link
else:
print('No results found.')
return None
except Exception as e:
print(f'Error fetching YouTube link: {e}')
return None
def update_y99_bio(auth_token, song_title, youtube_link, bio_template):
song_title = song_title or ''
youtube_link = youtube_link or ''
bio = bio_template.replace('{song_title}', song_title).replace('{youtube_link}', youtube_link)
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
}
data = {
'description': bio,
'auth': auth_token
}
y99_url = 'https://api2.y99.in/api.vf.random/api.php/user/profile/update?='
response = requests.post(y99_url, headers=headers, data=data)
return response.status_code == 200
def monitor_task(username, auth_token, bio_template):
last_song = None
while monitoring_active.get(username, False):
song_name, artist_name = get_current_song(api_key, username)
if song_name and artist_name:
song_title = f'Now Playing: {song_name} - {artist_name}'
if song_title != last_song:
youtube_link = get_youtube_link(song_name, artist_name)
if update_y99_bio(auth_token, song_title, youtube_link, bio_template):
print(f'Bio updated with: {song_title} - {youtube_link}')
last_song = song_title
else:
print('Error updating bio.')
time.sleep(30)
@app.route('/', methods=['GET', 'POST'])
def index():
return render_template('index.html')
@app.route('/start_monitoring', methods=['POST'])
def start_monitoring():
username = request.form['lastfm_username']
auth_token = request.form['y99_session_token']
bio_template = request.form['bio_template']
# Activate monitoring
monitoring_active[username] = True
# Start the monitoring thread
thread = threading.Thread(target=monitor_task, args=(username, auth_token, bio_template))
thread.start()
return redirect(url_for('index'))
@app.route('/stop_monitoring', methods=['POST'])
def stop_monitoring():
username = request.form['lastfm_username']
monitoring_active[username] = False
return redirect(url_for('index'))
if __name__ == '__main__':
#app.run(host='0.0.0.0', port=5000, debug=True)
app.run(port=5000)