sabreW4K3

joined 2 years ago
MODERATOR OF
wtf
[–] sabreW4K3@lemmy.tf 1 points 2 years ago

So I tried all the different methods you mentioned but everyone fails and so when I took a deep breath, I figured that I'm probably not understanding properly how it works.

I can say this without a doubt though, the needless complexity regarding these rating tags is stupid. I don't understand why people thought this made sense. It's illogical!

[–] sabreW4K3@lemmy.tf 1 points 2 years ago* (last edited 2 years ago) (1 children)

I'm getting 0.66 when I do get a rating. But I'm definitely not getting that to print. Here's the full file

import os
import mutagen
import requests
import urllib.parse
from mutagen.easyid3 import EasyID3
from mutagen.id3 import ID3
from pprint import pprint

# Navidrome credentials
navidrome_url = "http://navidrome.local:4533"
navidrome_username = "your-username"
navidrome_password = "your-password"
hex_encoded_pass = navidrome_password.encode().hex()
headers = None

# Directory containing MP3 files
mp3_directory = "/nfs"

def extract_rating(mp3_file):
    global rating
    audio = mutagen.File(mp3_file)
    tags = ID3(mp3_file)

    print(tags["TXXX:FMPS_Rating_AMarok_Score"]) #Gives KeyError

    for frame in tags.getall("TXXX"):
      rating = frame #This is terrible. The last key is the rating and since I can't call it by the key, I'm just refilling the variable
      print(rating)

# It was moaning about strings and floats, so commented out
#    if rating >= 1.0:
#      return 5
#    elif rating >= 0.8:
#      return 4
#    elif rating >= 0.6:
#      return 3
#    elif rating >= 0.4:
#      return 2
#    elif rating >= 0.2:
#      return 1
#    else:
#      return 0

#    return rating

def update_rating_on_navidrome(track_id, rating):
    url = f"{navidrome_url}/rest/setRating?id={track_id}&u={navidrome_username}&p=enc: {hex_encoded_pass}&v=1.12.0&rating={rating}"
    data = {"rating": rating}
    response = requests.get(url, headers=headers, json=data)

def find_track_id_on_navidrome(mp3_file):
    url = urllib.parse(url)
    url = f"{navidrome_url}/rest/getSong?path={mp3_file.encode()}&u={navidrome_username}&p=enc: {hex_encoded_pass}&v=1.12.0"
    response = requests.get(url, headers=headers, json=data)
    return url[track_id]

    if response.status_code == 204:
        print(f"Rating updated successfully for track {track_id}")
    else:
        print(f"Failed to update rating for track {track_id}: {response.text}")

print("hello")
#test = 
print(os.listdir(mp3_directory))

for foldername in os.listdir(mp3_directory):
  folderpath = "/".join([mp3_directory, foldername])
  for filename in os.listdir(folderpath):
    if filename.endswith(".mp3"):
        mp3_file = "/".join([folderpath, filename])
        rating = extract_rating(mp3_file)
        print(mp3_file, rating, sep= "_____")
        print(rating)
#
#        # Implement logic to find the track ID on Navidrome based on filename or other metadata
#        track_id = find_track_id_on_navidrome(filename)  # Replace with your implementation#
#
#        if track_id:
#            update_rating_on_navidrome(track_id, rating)
#        else:
#            print(f"Track ID not found on Navidrome for {filename}")

Have I called something erroneously that would mess it up?

Sorry if it's terrible to read, up until I started trying to do this, I had never touched Python before and haven't attempted to code for years.

[–] sabreW4K3@lemmy.tf 1 points 2 years ago

For testing purposes, same file every time, this one: https://file.coffee/u/IxKmfKfUwgPybq_vv8YJc.mp3

[–] sabreW4K3@lemmy.tf 1 points 2 years ago (2 children)

Thank you so much.

One more question, do I have to point it directly at the directory I want or can I point it at one above? Reason being, I have a film directory which I will point Jellyfin to too.

[–] sabreW4K3@lemmy.tf 1 points 2 years ago (4 children)

So this is my preferred method, but I found the blog post really confusing. Subsequently, it failed.

  navidrome:
    container_name: navidrome
    image: deluan/navidrome:latest
    ports:
      - "4533:4533"
    environment:
      ND_SCANSCHEDULE: 1h
      ND_LOGLEVEL: info
    volumes:
      - "/opt/navidrome/data:/data"
      - "/nfs/Shared Music:/music:ro"
      - type: volume
      - source: nfs
      - target: /nfs
      - volume:
        nocopy: true
  volumes:
    nfs:
      driver: local
      driver_opts:
        type: nfs
        o: "addr=XXX.XXX.XXX.XXX,nolock,soft,rw"
        device: ":/mnt/HD/Public"

What am I doing wrong?

[–] sabreW4K3@lemmy.tf 55 points 2 years ago (8 children)

Containerception!

[–] sabreW4K3@lemmy.tf 127 points 2 years ago (12 children)

Piracy and Porn rule the Internet

[–] sabreW4K3@lemmy.tf 3 points 2 years ago (1 children)

Thanks for the useful insight.

[–] sabreW4K3@lemmy.tf 8 points 2 years ago (4 children)

Huh? Why not? Being able to stream multiple languages in a single cinema showing or supporting those with hearing difficulties is amazing.

Even going to clubs and from the outside it looks like a bunch of weirdos dancing to themselves is amazing.

[–] sabreW4K3@lemmy.tf 23 points 2 years ago (7 children)

Bluetooth broadcasting. One device will be able to stream to hundreds and thousands of devices.

[–] sabreW4K3@lemmy.tf 3 points 2 years ago (3 children)

You still have maps and GPS though.

[–] sabreW4K3@lemmy.tf 1 points 2 years ago (6 children)

You shine a torch at someone in the dark, you can see more than just them though

view more: ‹ prev next ›