Yoas1 13 Posted February 19, 2025 Author Posted February 19, 2025 9 hours ago, sh0rty said: With the working combo, I get the telegram messages twice. I fixed a bug, working without a specific group. And change the config.yaml exampleย Try version yoas1/emby-telegram-notifier:v0.2, let me know if it works properly. ย 3 hours ago, sh0rty said: Nevertheless, best Emby Telegram plugin around!ย Thanks for the kind words, I appreciate it. 1
sh0rty 714 Posted February 20, 2025 Posted February 20, 2025 @Yoas1Everythings working now. Well done! 1
Yoas1 13 Posted March 29, 2025 Author Posted March 29, 2025 I published new version to notifier: yoas1/emby-telegram-notifier:v0.3 update: Add movies/series Community Rating. For admins: Users add to favorites notification. 1
sh0rty 714 Posted May 28, 2025 Posted May 28, 2025 (edited) @Yoas1One thing I recognized: When a new movie or episode is added, i get the notification twice. ย Is it possible that Emby sends two library.new events, when e.g. the MediaInfo Tool is involved? Could the code be modified to cache event type and ID and ignore new webhook trigger if the same event is already sent? Something like this:ย ย from flask import Flask, request, abort import requests from os import environ import yaml import time app = Flask(__name__) last_events = {} # Cache for Duplication Check def get_token(): with open("/config/config.yaml") as data: info_data = yaml.safe_load(data) token = info_data["token"] token = token[0] return token def get_emby_url(): with open("/config/config.yaml") as data: info_data = yaml.safe_load(data) server = info_data["emby-server"] server = server[0] return server t_token = get_token() url_send_photo = f"https://api.telegram.org/bot{t_token}/sendPhoto" url_send_message = f"https://api.telegram.org/bot{t_token}/sendMessage" e_server = get_emby_url() def get_admins(): with open("/config/config.yaml") as data: info_data = yaml.safe_load(data) try: admins = info_data["admins"] return admins except KeyError: return None def get_users(): with open("/config/config.yaml") as data: info_data = yaml.safe_load(data) try: users = info_data["users"] return users except KeyError: return None def convert_list(string): li = list(string.split(" ")) return li def get_icon(argument): switcher = { "playback.start": "โถ ", "playback.stop": "โน ", "playback.pause": "โธ ", "playback.unpause": "โฏ ", "library.deleted": "๐ ", "item.markunplayed": "", "item.markplayed": "", "system.updateavailable": "", "user.authenticationfailed": "", "user.authenticated": "", "system.serverrestartrequired": "", "plugins.pluginuninstalled": "", "plugins.plugininstalled": "", } return switcher.get(argument, "") def update(): global response item = response["Server"] server_version = item["Version"] item = response["PackageVersionInfo"] new_version = item["versionStr"] info = item["infoUrl"] desc = item["description"] get_event_marked = response["Event"] icon = get_icon(get_event_marked) text = f"{icon} Update from version {server_version} to {new_version} available \nDescription: {desc} \nMore info: {info}" url = f"https://api.telegram.org/bot{t_token}/sendMessage?chat_id={send_id}&text={text}" requests.post(url) def rate(): global response user = response['User']['Name'] item = response['Item']['Name'] add_favorite = response['Item']['UserData']['IsFavorite'] if add_favorite == True: text = user + '\n added: ' + item + ' to favorites' elif add_favorite == False: text = user + '\n remove: ' + item + ' from favorites' url = f"https://api.telegram.org/bot{t_token}/sendMessage?chat_id={send_id}&text={text}" requests.post(url) def marked(): global response, text get_event_marked = response["Event"] response = response["Item"] icon = get_icon(get_event_marked) if "item.markplayed" in get_event_marked: if response["Type"] == "Movie": movie_name = response["Name"] text = f"{icon} Marked-played: {movie_name}" elif response["Type"] == "Episode": series_name = response["SeriesName"] season = response["SeasonName"] episode_name = response["Name"] episode_nun = response["IndexNumber"] text = f"{icon} Marked-played: {series_name} {season} episode {episode_nun} - {episode_name}" elif "item.markunplayed" in get_event_marked: if response["Type"] == "Movie": movie_name = response["Name"] text = f"{icon} Marked-unplayed: {movie_name}" elif response["Type"] == "Episode": series_name = response["SeriesName"] season = response["SeasonName"] episode_name = response["Name"] episode_nun = response["IndexNumber"] text = f"{icon} Marked-unplayed: {series_name} {season} episode {episode_nun} - {episode_name}" url = f"https://api.telegram.org/bot{t_token}/sendMessage?chat_id={send_id}&text={text}" requests.post(url) def send_message(): get_event = response["Event"] text_new = response["Title"] icon = get_icon(get_event) data = { "chat_id": send_id, "caption": text_new, "parse_mode": "Markdown", "text": icon + text_new, } requests.post(url_send_message, data=data) def lib_new(): text_new = response["Title"] try: desc = response["Description"] except KeyError: desc = "**Can't get a description from the server, edit its identity manually**" item = response["Item"] photo_id = item["Id"] try: rating = item['CommunityRating'] except: rating = None base_photo_url = f"{e_server}/emby/Items/{photo_id}/Images/Primary" if photo_id else None image_response = requests.get(base_photo_url) image = ("photo.jpg", image_response.content, "image/jpeg") try: data_new = { "chat_id": send_id, "caption": text_new + '\n' + 'Rating: ' + str(rating) + '' + '\n\nDescription: ' + desc, "parse_mode": "Markdown" } except: data_new = { "chat_id": send_id, "caption": text_new + '\n\nDescription: ' + desc, "parse_mode": "Markdown" } requests.post(url_send_photo, data=data_new, files={"photo": image}) def switch_case(argument): switcher = { "playback.start": send_message, "playback.stop": send_message, "playback.pause": send_message, "playback.unpause": send_message, "library.new": lib_new, "library.deleted": send_message, "item.markunplayed": marked, "item.markplayed": marked, "system.updateavailable": update, "user.authenticationfailed": send_message, "user.authenticated": send_message, "system.serverrestartrequired": send_message, "plugins.pluginuninstalled": send_message, "plugins.plugininstalled": send_message, 'item.rate': rate, } return switcher.get(argument, "") @app.route("/webhook", methods=["POST"]) def webhook(): global response, send_id if request.method == "POST": response = request.json get_event_now = response["Event"] item_id = response.get("Item", {}).get("Id", "") key = f"{get_event_now}-{item_id}" now = time.time() if key in last_events and now - last_events[key] < 5: print(">>> Duplicate event ignored:", key) return "duplicate ignored", 200 last_events[key] = now admin_id = get_admins() if admin_id is not None: for i in range(len(admin_id)): send_id = admin_id[i] print(">>> Event:", get_event_now) if get_event_now.startswith(( "playback.start", "playback.stop", "playback.pause", "playback.unpause", "library.new", "library.deleted", "item.markunplayed", "item.markplayed", "system.updateavailable", "user.authenticationfailed", "user.authenticated", "system.serverrestartrequired", "plugins.pluginuninstalled", "plugins.plugininstalled", 'item.rate', )): switch_case(get_event_now)() else: send_message() return "success", 200 else: abort(400) if __name__ == "__main__": app.run() ย Edited May 28, 2025 by sh0rty
Yoas1 13 Posted May 28, 2025 Author Posted May 28, 2025 @sh0rtyCan you send meย documentation for the tool you used? I want to build a test environment to fix your problem This is something new that started happening since you installedย the MediaInfo Tool? I would appreciate it if you could open an issue on GitHub for me, so I don't miss the fix
sh0rty 714 Posted May 28, 2025 Posted May 28, 2025 6 hours ago, Yoas1 said: @sh0rtyCan you send meย documentation for the tool you used? I want to build a test environment to fix your problem This is something new that started happening since you installedย the MediaInfo Tool? I would appreciate it if you could open an issue on GitHub for me, so I don't miss the fix Thats the problem, it began on the 9th April. MediaInfo Tool was just a guess, but I have it installed for a long time, long before you released your script and it worked with it until begin of April. I also did not install anything new on the Emby server. Issue is opened on GH. Thanks!
Yoas1 13 Posted June 10, 2025 Author Posted June 10, 2025 (edited) On 28/05/2025 at 22:04, sh0rty said: Thats the problem, it began on the 9th April. MediaInfo Tool was just a guess, but I have it installed for a long time, long before you released your script and it worked with it until begin of April. I also did not install anything new on the Emby server. Issue is opened on GH. Thanks! ย @sh0rtyHey mate, I made a change in the version regarding the duplicates on your emby-notifier. Can you check it out and let me know? Use the version:ย yoas1/emby-telegram-notifier:v0.3.1ย Edited June 10, 2025 by Yoas1
howllor 26 Posted September 8, 2025 Posted September 8, 2025 (edited) I can't get it to work, it uses the wrong IP addressย Edited September 8, 2025 by howllor
Luke 42077 Posted September 8, 2025 Posted September 8, 2025 7 hours ago, howllor said: I can't get it to work, it uses the wrong IP addressย Hi, why not just use the plugin in the Emby plugin catalog instead?
howllor 26 Posted September 8, 2025 Posted September 8, 2025 49 minutes ago, Luke said: Hi, why not just use the plugin in the Emby plugin catalog instead? And which one would that be?
Luke 42077 Posted September 8, 2025 Posted September 8, 2025 Sorry, my mistake. I forgot that it's not in the catalog. ย
howllor 26 Posted September 8, 2025 Posted September 8, 2025 1 hour ago, Luke said: Sorry, my mistake. I forgot that it's not in the catalog. ย Yep I've got that one installed, and it works fine, but was interested in getting one that adds posters to the updates
Luke 42077 Posted September 8, 2025 Posted September 8, 2025 11 minutes ago, howllor said: Yep I've got that one installed, and it works fine, but was interested in getting one that adds posters to the updates I'll mention it to the developer, so please follow along in that topic.
Yoas1 13 Posted September 9, 2025 Author Posted September 9, 2025 On 08/09/2025 at 12:42, howllor said: I can't get it to work, it uses the wrong IP addressย Hey, can you send me the configurations you made in a private message? Both for the container and the webhook. Also, a screenshot of where you saw it was getting a different IP address. I'll try to help figure out the problem.
howllor 26 Posted September 9, 2025 Posted September 9, 2025 4 hours ago, Yoas1 said: Hey, can you send me the configurations you made in a private message? Both for the container and the webhook. Also, a screenshot of where you saw it was getting a different IP address. I'll try to help figure out the problem. I'll see if I can sit with it again with in a day or two, thank you
howllor 26 Posted September 10, 2025 Posted September 10, 2025 (edited) Got it working now, no idea what I did wrong last time around Edit: this is just me being nitpicky, but I would love a colon between "new" and the media title in the notification. Edited September 10, 2025 by howllor
Yoas1 13 Posted September 10, 2025 Author Posted September 10, 2025 2 hours ago, howllor said: Got it working now, no idea what I did wrong last time around Edit: this is just me being nitpicky, but I would love a colon between "new" and the media title in the notification. Great, I'm glad to hear that Can you open a GitHub request for this? I'm always happy to get new requests and ideas https://github.com/Yoas1/emby-telegram-notifier-/issues
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now