Jump to content

Telegram Notifications Plugin


darkside40

Recommended Posts

Dicken
19 hours ago, darkside40 said:

Here you have a specially crafted version which only include the Title until i have a real solution.

@Lukewhat about the thing of integration the Cover?

Emby.Plugin.TelegramNotification.dll 34.5 kB · 1 download

Thanks for that. It would also be cool if there was an option to pass the folder name instead of the title like in the old version.

I specifically named all of my folders like this: Title (Source) (Year).

Example: Ray Donovan - The Movie (Blu-ray) (2022)

Link to comment
Share on other sites

darkside40

Beeing really honest and dont know how often i have written this in this Thread, it is even mentioned in the start post:

"It simply forwards the Messages of the Emby Notification Framework to a Chat or Channel. Not more, not less. Sorry no fancy posters etc. because the Standard Notifications of Emby dont support it."

The problem is simple: There is no documentation for Plugin Developers. Most of the Plugins which are working for a long time are based on the E-Mail Plugin. And there you can only send Title and Description. No Covers, no IMDB ID, no folder name, no nothing more.

Mayby @Lukecan tell me that there is also a "request.imdbid" etc. if not it is only possible if you scrape it out of the DB by youreself. Thats a whole lot of work because there is no documentation and the fact that Emby is closed source.

It is doable, one guy did it for Discord, very advanced plugin which broke regulary, and afaik is now unmaintained if i recall correctly.

Link to comment
Share on other sites

Dicken

@LukeI would really appreciate documentation for plugin developers. It would be in the interest of all users. Please support the developers. @darkside40 has often asked for this kind of help here, if I'm not mistaken.

Link to comment
Share on other sites

Anthony Musgrove

The system is fairly large, even with ScripterX, I have spent hours and hours poking through the libraries and exposed functionality.  I find it kind of fun.

Link to comment
Share on other sites

muppet4k

Everybody should open a ticket on emby GitHub would be funny 😂😂😂

maybe then we get some more documentation 

 

Link to comment
Share on other sites

16 hours ago, darkside40 said:

Beeing really honest and dont know how often i have written this in this Thread, it is even mentioned in the start post:

"It simply forwards the Messages of the Emby Notification Framework to a Chat or Channel. Not more, not less. Sorry no fancy posters etc. because the Standard Notifications of Emby dont support it."

The problem is simple: There is no documentation for Plugin Developers. Most of the Plugins which are working for a long time are based on the E-Mail Plugin. And there you can only send Title and Description. No Covers, no IMDB ID, no folder name, no nothing more.

Mayby @Lukecan tell me that there is also a "request.imdbid" etc. if not it is only possible if you scrape it out of the DB by youreself. Thats a whole lot of work because there is no documentation and the fact that Emby is closed source.

It is doable, one guy did it for Discord, very advanced plugin which broke regulary, and afaik is now unmaintained if i recall correctly.

To get  the imdbid for the item, add this using statement:


using MediaBrowser.Model.Entities;

Then in your SendNotification method:

            var imdbId = request.Item?.GetProviderId("imdb");

 

Link to comment
Share on other sites

On 2/23/2024 at 7:55 PM, Luke said:

For images, how do you feed an image into Telegram?

In other words, if you tell me what you need from the Telegram side of things, then I'll help with the Emby side of it.

Link to comment
Share on other sites

muppet4k
On 2/23/2024 at 1:55 PM, darkside40 said:

That was already an issue at times when Emby was Open Source.

 

On 2/23/2024 at 1:55 PM, darkside40 said:

That was already an issue at times when Emby was Open Source.

@darkside40Luke give you some information 🙂

  • Thanks 1
Link to comment
Share on other sites

muppet4k
On 12/5/2023 at 7:20 PM, jdazzle44 said:

I created a python script thats very similar to this plugiin but with poster . You can find it on github if you're interested.

Example of a movie and series below.

 

 

Hi ,

 

port 5000 is already used by Synology … I changed it in the configuration but had no effect when I start the docker again 😞

Link to comment
Share on other sites

darkside40
On 2/25/2024 at 7:29 AM, Luke said:

In other words, if you tell me what you need from the Telegram side of things, then I'll help with the Emby side of it.

I would need a local path to the corresponding image, that could be fed into the Telegram API.

@muppet4k yes i see updates in this thread, no need to send me an PM because of that. If sending images is a high priority issue for you with this plugin you are free to fork it, or to send a PR etc.

 

Link to comment
Share on other sites

muppet4k
17 minutes ago, darkside40 said:

I would need a local path to the corresponding image, that could be fed into the Telegram API.

@muppet4k yes i see updates in this thread, no need to send me an PM because of that. If sending images is a high priority issue for you with this plugin you are free to fork it, or to send a PR etc.

 

Sorry that I sent a PM but thank you that you mention it public … what a friendly way!!

no idea what a PR is for you but it’s ok 

I give up with all this stupid plugins , webhooks not working no documentation and the terrible time here …

bye 

  • Facepalm 1
Link to comment
Share on other sites

Dicken

Hey, maybe I have a little workaround or impetus for further development for some people.

I'll say upfront that I definitely don't have as much knowledge of the subject as @darkside40 or the other developers, but for me it works temporarily:

What have I done:

 

1. For new media data, I have a webhook in JSON format sent to my own data point in iobroker via Emby.

Content example:

Spoiler
{
  "Title": "placeholder",
  "Description": "placeholder",
  "Date": "placeholder",
  "Event": "library.new",
  "Item": {
    "Name": "placeholder",
    "OriginalTitle": "placeholder",
    "ServerId": "placeholder",
    "Id": "placeholder",
    "DateCreated": "placeholder",
    "Container": "placeholder",
    "SortName": "placeholder",
    "PremiereDate": "placeholder",
    "ExternalUrls": [
      {
        "Name": "IMDb",
        "Url": "placeholder"
      },
      {
        "Name": "TheMovieDb",
        "Url": "placeholder"
      },
      {
        "Name": "Trakt",
        "Url": "placeholder"
      }
    ],
    "Path": "placeholder",
    "OfficialRating": "placeholder",
    "Overview": "placeholder",
    "Taglines": [],
    "Genres": [
      "placeholder",
      "placeholder"
    ],
    "CommunityRating": 4,
    "RunTimeTicks": 52241280000,
    "Size": 854904891,
    "FileName": "placeholder",
    "Bitrate": 1309163,
    "ProductionYear": 2023,
    "RemoteTrailers": [
      {
        "Url": "placeholder"
      }
    ],
    "ProviderIds": {
      "Imdb": "placeholder",
      "Tmdb": "placeholder"
    },
    "IsFolder": false,
    "ParentId": "placeholder",
    "Type": "placeholder",
    "Studios": [],
    "GenreItems": [
      {
        "Name": "Familie",
        "Id": 53269
      },
      {
        "Name": "Komödie",
        "Id": 53276
      }
    ],
    "TagItems": [
      {
        "Name": "school",
        "Id": 218532
      },
      {
        "Name": "kids",
        "Id": 353845
      }
    ],
    "PrimaryImageAspectRatio": 0.7222222222222222,
    "ImageTags": {
      "Primary": "placeholder"
    },
    "BackdropImageTags": [
      "placeholder"
    ],
    "MediaType": "Video",
    "Width": 720,
    "Height": 300
  },
  "Server": {
    "Name": "placeholder",
    "Id": "placeholder",
    "Version": "4.8.3.0"
  }
}

 

 

2. Then I checked what a cover path looks like in Emby WebIF:

In my case:
http://<embyip>:<embyport>/emby/Items/<Item.Id>/Images/Primary?tag=<Item.ImageTags.Primary>

 

3. I extract the required values into variables using Javascript or Blockly:

In my case:
<Item.Id>
<Item.ImageTags.Primary>

and build a new URL from the variables.

 

4. I drag the image to the iobroker using wget via the created URL and create a temporary file (in my case: cover.jpg)

 

5. I then send the file to Telegram via the Telegram adapter in iobroker

 

Every time new media arrives on Emby, the data point is described with the new JSON content and the cover.jpg is replaced and sent to Telegram.
The script runs automatically when the value in my data point changes.

 

Of course, the JSON that comes via webhook also contains a bunch of other data about the film that could be further processed.

Not the most elegant solution, but it was quite helpful for me in understanding Javascript and dealing with JSON.

Certainly not everyone has iobroker, but anyone who knows Javascript can definitely do it without iobroker :D

I hope it is somewhat understandable and sorry for my English (Google Translator :D )

Edited by Dicken
Link to comment
Share on other sites

muppet4k
5 minutes ago, Dicken said:

Hey, maybe I have a little workaround or impetus for further development for some people.

I'll say upfront that I definitely don't have as much knowledge of the subject as @darkside40 or the other developers, but for me it works temporarily:

What have I done:

 

1. For new media data, I have a webhook in JSON format sent to my own data point in iobroker via Emby.

Content example:

  Reveal hidden contents
{
  "Title": "placeholder",
  "Description": "placeholder",
  "Date": "placeholder",
  "Event": "library.new",
  "Item": {
    "Name": "placeholder",
    "OriginalTitle": "placeholder",
    "ServerId": "placeholder",
    "Id": "placeholder",
    "DateCreated": "placeholder",
    "Container": "placeholder",
    "SortName": "placeholder",
    "PremiereDate": "placeholder",
    "ExternalUrls": [
      {
        "Name": "IMDb",
        "Url": "placeholder"
      },
      {
        "Name": "TheMovieDb",
        "Url": "placeholder"
      },
      {
        "Name": "Trakt",
        "Url": "placeholder"
      }
    ],
    "Path": "placeholder",
    "OfficialRating": "placeholder",
    "Overview": "placeholder",
    "Taglines": [],
    "Genres": [
      "placeholder",
      "placeholder"
    ],
    "CommunityRating": 4,
    "RunTimeTicks": 52241280000,
    "Size": 854904891,
    "FileName": "placeholder",
    "Bitrate": 1309163,
    "ProductionYear": 2023,
    "RemoteTrailers": [
      {
        "Url": "placeholder"
      }
    ],
    "ProviderIds": {
      "Imdb": "placeholder",
      "Tmdb": "placeholder"
    },
    "IsFolder": false,
    "ParentId": "placeholder",
    "Type": "placeholder",
    "Studios": [],
    "GenreItems": [
      {
        "Name": "Familie",
        "Id": 53269
      },
      {
        "Name": "Komödie",
        "Id": 53276
      }
    ],
    "TagItems": [
      {
        "Name": "school",
        "Id": 218532
      },
      {
        "Name": "kids",
        "Id": 353845
      }
    ],
    "PrimaryImageAspectRatio": 0.7222222222222222,
    "ImageTags": {
      "Primary": "placeholder"
    },
    "BackdropImageTags": [
      "placeholder"
    ],
    "MediaType": "Video",
    "Width": 720,
    "Height": 300
  },
  "Server": {
    "Name": "placeholder",
    "Id": "placeholder",
    "Version": "4.8.3.0"
  }
}

 

 

2. Then I checked what a cover path looks like in Emby WebIF:

In my case:
http://<embyip>:<embyport>/emby/Items/<Item.Id>/Images/Primary?tag=<Item.ImageTags.Primary>

 

3. I extract the required values into variables using Javascript or Blockly:

In my case:
<Item.Id>
<Item.ImageTags.Primary>

and build a new URL from the variables.

 

4. I drag the image to the iobroker using wget via the created URL and create a temporary file (in my case: cover.jpg)

 

5. I then send the file to Telegram via the Telegram adapter in iobroker

 

Every time new media arrives on Emby, the data point is described with the new JSON content and the cover.jpg is replaced and sent to Telegram.
The script runs automatically when the value in my data point changes.

 

Of course, the JSON that comes via webhook also contains a bunch of other data about the film that could be further processed.

Not the most elegant solution, but it was quite helpful for me in understanding Javascript and dealing with JSON.

Certainly not everyone has iobroker, but anyone who knows Javascript can definitely do it without iobroker :D

I hope it is somewhat understandable and sorry for my English (Google Translator :D )

Can you show your JS or blockly in Iobroker please 🙂 

Link to comment
Share on other sites

darkside40

Of course you can build such solutions using Webhook and some external tool like iobroker, nodered etc. 
 

The simple downpoints are: afaik Webhooks require Emby Premium, another Service like nodered etc is involved instead of a simple Plugin. 
 

But fair enough, i think this approacj can be more flexible than the Emby Notification Framework

Link to comment
Share on other sites

Dicken
2 hours ago, muppet4k said:

Can you show your JS or blockly in Iobroker please 🙂 

Of course, here's the Blockly:

Spoiler

cover_telegram_blockly.png.816b211976ca9c4c43beeb35a4c097bc.png

Und hier als Javascript-Code:

Spoiler
var FilmID, wgetCover, Cover;


on({ id: [].concat(['0_userdata.0.Emby.NeuerFilm']), change: 'ne' }, async (obj) => {
  let value = obj.state.val;
  let oldValue = obj.oldState.val;
  FilmID = (await jsonataExpression(getAttr((function () { try { return JSON.parse(getState('0_userdata.0.Emby.NeuerFilm').val); } catch (e) { return {}; }})(), 'Item'),'Id'));
  wgetCover = ['wget --output-document /opt/iobroker/iobroker-data/files/0_userdata.0/emby.cover/cover.jpg "http://<embyip>:<embyport>/emby/Items/',FilmID,'/Images/Primary"'].join('');
  exec(wgetCover);
  Cover = '/opt/iobroker/iobroker-data/files/0_userdata.0/emby.cover/cover.jpg';
  sendTo("telegram", "send", {
      text: Cover
  });
});

 

I only noticed one problem, which can certainly be solved: As a test, I added 2 films one after the other. The web hock was also sent twice within 5 seconds of each other. But the Blockly script is apparently too slow and only sends the cover of the last film.

 

1 hour ago, darkside40 said:

Of course you can build such solutions using Webhook and some external tool like iobroker, nodered etc. 
 

The simple downpoints are: afaik Webhooks require Emby Premium, another Service like nodered etc is involved instead of a simple Plugin. 
 

But fair enough, i think this approacj can be more flexible than the Emby Notification Framework

Oh, I didn't know that Webhook required Emby Premium. Then of course that's stupid. But it would be so simple if a GET command for the library.new event were built into the API.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
emLmSx
On 19.10.2022 at 19:00, svyaznoy362 said:

Привет.

Люк , ссылки на возможность получения изображений.

 

photo_2022-10-19_17-59-05.jpg

Скриншот_1.jpg

photo_2022-10-19_13-17-04.jpg

Привествую,а как ты сделал чтобы к телеграм бот отправить с картинками? спасибо

Link to comment
Share on other sites

  • 3 weeks later...

I updated some code but since my server is not visible outside my network, I don't know if that's what's causing an error in the request to the Telegram API when sending a photo. I commented in another forum that I am not a developer of Emby itself and to top it off, there is not a documentation explicit enough on how to use the Emby core. I attach the plugin in case someone can try it and say if it works, it sends the notification without a photo perfectly but the one that contains the image URL results in "BadRequest".

Emby.Plugin.TelegramNotification.dll

Link to comment
Share on other sites

5 hours ago, Jekill said:

Actualicé algo de código pero como mi servidor no es visible fuera de mi red, no sé si eso es lo que está causando un error en la solicitud a la API de Telegram al enviar una foto. Comenté en otro foro que no soy desarrollador de Emby en sí y para colmo, no hay documentación lo suficientemente explícita sobre cómo usar el núcleo de Emby. Adjunto el plugin por si alguien puede probarlo y decir si funciona, envía la notificación sin foto perfectamente pero la que contiene la URL de la imagen da como resultado «BadRequest».

Emby.Plugin.TelegramNotification.dll 43,5 kB · 0 descargas

Edit:

As long as the Emby server can be seen from the Telegram servers, the notification is sent perfectly along with the image. If anyone knows how to send the file instead of the image URL, please help improve the plugin.

Edited by Jekill
Link to comment
Share on other sites

darkside40
On 4/22/2024 at 10:19 PM, Jekill said:

Edit:

As long as the Emby server can be seen from the Telegram servers, the notification is sent perfectly along with the image. If anyone knows how to send the file instead of the image URL, please help improve the plugin.

Is your source somewhere available?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...