Code Monkey home page Code Monkey logo

Comments (4)

Sarin-jacob avatar Sarin-jacob commented on June 10, 2024 2

@Pabsilon I had the same issue, what I did at the end was use wizarr API to get the json from endpoint wizarr_base_url/api/users then extracted 'id' and 'email' from it. then post '{email: < email>}'to jellyseerr_url/api/v1/user/<id>/settings/main if id alligns.
You can modify the following python code and add it as Cron job


import requests

# Jellyseerr, wizarr instance variables. MODIFY These!!
J_url=f"http://localhost:5055/api/v1/"
W_url=f"http://localhost:5690/api/"
J_apikey="123456-1234-1234-1234-123456123456dc"
W_apikey="652d4b8b-0b7b-4b7b-8b7b-0b7b4b7b8b7b"

J_header={
    'accept': 'application/json',
    'Authorization': f'Bearer {J_apikey}'
}

W_header={
    'accept': 'application/json',
    'Authorization': f'Bearer {W_apikey}'
}

users=requests.get(J_url+"users", headers=J_header).json()
J_users=[]
for user in users:
    J_users.append((user["jellyfinUsername"], user["id"]))

users=requests.get(W_url+"users", headers=W_header).json()
W_users=[]
for user in users:
    W_users.append((user["username"],user["email"]))

for user in J_users:
    for user2 in W_users:
        if user[0]==user2[0]:
            try:
                requests.post(W_url+f"user/{user[1]}/settings/main", headers=J_header, json={'email':user2[1]},timeout=8)
            except:
                print(f"Error updating user {user[0]}")

This issue is few months old, still I hope someone would benefit from this :)

NB: I haven't tested this but it should work, unless there's some change in API. You can refer the API docs from http://wizarr_ip:5690/api/docs and jellyseerr_url/api-docs (might need to enable swagger UI in environment variables)

from wizarr.

realashleybailey avatar realashleybailey commented on June 10, 2024 1

Wizarr does not create users on Jellyseerr and thus does not hand emails to Jellyseerr, Wizarr triggers Jellyseerr to import Jellyfin users, this is not a bug, if this is functionality you would like I would suggest adding it over at https://features.wizarr.dev

from wizarr.

Pabsilon avatar Pabsilon commented on June 10, 2024 1

Hey, @Sarin-jacob ,
Thanks for your script. It didn't work on my instance, maybe because a typo on the jellyseer urls (endpoint is /users and not /user) so I modified a bit so that it just iterates on jellyseer users without email (either None, "" or equal to username, that's how newly created users show for me) and then tries to match them to wizarrrr users that do have an email.

import requests

# Jellyseerr, wizarr instance variables. MODIFY These!!
J_url=f"http://<jellyseerAddress:port>/api/v1/"
W_url=f"http://<wizarrrrAddress:port>/api/"
J_apikey="<JellySeerApiKey>" # Get it from Settings / General / API Key"
W_apikey="<WizarrrrApiKey>" # Create a new one in Admin Dasboard / Settings / API Keys / Big Red Plus button

# Header for Jellyseer
J_header={
    'accept': 'application/json',
    'X-Api-Key': f'{J_apikey}'
}

# Header for wizarrrr
W_header={
    'accept': 'application/json',
    'Authorization': f'Bearer {W_apikey}'
}

# Getting the list of users from Jellyeer that don't have a mail
users=requests.get(J_url+"user?take=50&skip=0&sort=created", headers=J_header).json()
J_users=[]
for user in users["results"]:
    # In my case, newly created user in jellyseer have the user set as email
    if user["email"] is None or user["email"]=="" or user["email"]==user["jellyfinUsername"]:
        J_users.append((user["jellyfinUsername"], user["id"]))

# Getting the list of all users user from wizarrrr that have a mail set
users=requests.get(W_url+"users", headers=W_header).json()
W_users=[]
for user in users:
    if user["email"] is not None:
        W_users.append((user["username"],user["email"]))

# Calling Jellyseer to set email // Twice because sometimes it doesn't work when it's None
for jelly_user in J_users:
    for wizarrrr_user in W_users:
        if jelly_user[0] == wizarrrr_user[0]:
            # Request Twice because when the email is set to username, it takes a couple attempts...
            req = requests.post(J_url+f"user/{jelly_user[1]}/settings/main", headers=J_header,  json={"email": wizarrrr_user[1]})
            req = requests.post(J_url+f"user/{jelly_user[1]}/settings/main", headers=J_header,  json={"email": wizarrrr_user[1]})

Again, thanks for the idea. It saves some time and avoids typing errors!

from wizarr.

JamsRepos avatar JamsRepos commented on June 10, 2024

This issue is few months old, still I hope someone would benefit from this :)

Very handy script, thanks for your contribution. I'll be sure to post this to users in the discord.

from wizarr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.