Search the Community
Showing results for tags 'script'.
-
Good evening all, I am extremely happy to present to you - Emby Scripter-X version 3.0 (up on the catalog now!) The major change in this version is -- Packages -- ! This gives you the opportunity to develop packages for Scripter X for others to install and use. And very soon, there will be a Packages catalog available that you'll be able to search for, and install community packages, straight from your Emby Administration Console. A package is written in Javascript. A Package requires 3 things - 1) a PackageInfo.json file, 2) a Package.js file, and 3) both these files zipped up together in a .ZIP file. PackageInfo.json provides vital information about your package to ScripterX. It's format is as follows :- { "Id": "scripterx.package.example", "Name": "Example Package", "Description": "An example package for the ScripterX package system.", "Author": "Anthony Musgrove", "Email": "anthony@emby-scripterx.info" } Package.js is the javascript file for your package - where all your code exists. This is the fun bit. Some important things to know about your script: - When your package is initialised by ScripterX (on installation, and on server startup), a function in your Package.js is executed. It is called _package_init(): function _package_init() { //do something here on package startup } - Your script can subscribe to ANY of the ScripterX events, by adding a function with the name _EventName, for example, if you wish to subscribe your package to the onAuthenticationFailed event, you'd simply enter: function _onAuthenticationFailed(context) { //do something here when someone fails to authenticate to emby. } *** Note, the parameter for these functions is context, which is the context of the event call. It contains all the information regarding token values, etc, that you have full access to. For example, to get the username of the attempted failed authentication, you could use :- function _onAuthenticationFailed(context) { var attempted_username = context.Token("%username%").value; } - Same goes for any of the other events, events being: onAuthenticationFailed, onAuthenticationSuccess, onLibraryScanComplete, onMediaItemAdded, onMediaItemRemoved, onMediaItemUpdated, onPlaybackStart, onPlaybackStopped, onScheduledTask, onSessionEnded, onSessionStarted, onCameraImageUploaded, onLiveTVRecordingStart, onLiveTVRecordingEnded, onScheduledTaskStart, onScheduledTaskEnded, onMediaItemAddedComplete, onPlaybackProgress - To log output from your package to the Emby server log, you can utilise the ScripterX.Log functions, they are :- ScripterX.Log.Info("Add an Info log entry to emby server log."); ScripterX.Log.Error("Add an Error log entry to emby server log."); - If you need timers, ScripterX has timers. You can simply create, delete, start, restart or stop a timer by using the following Timers commands : Create a timer that only elapses once, but can be restarted manually after its elapsed, by using .createOnce: ScripterX.Timers.createOnce("myTimer", 5000, "tmrMyTimer_Elapsed", null); or, create a timer that elapses every interval, without having to be restarted, by using .createRepeating: ScripterX.Timers.createRepeating("myRepeatingTimer", 10000, "tmrMyRepeatingTimer_Elapsed", null); - When your timer elapses, it will call the function set in as your callback. For example, when my timer elapses, it will call the following function: function tmrMyTimer_Elapsed(timer_name, timer_interval, objects) { //do something here when my timer elapses, the timer's name is given here too. //timer name is needed to start, stop, restart, delete etc. } - ScripterX supports webhook posts right from your javascript, you can perform a webhook post by using the ScripterX.Web functions, for example, in my _onPlaybackStart function, I want to post to a webhook every time someone starts playing a movie or TV show on my server, I can do this by: function _onPlaybackStart(context) { /* Send a webhook when (someone) plays (something) */ var api_url = "https://myapi.url.com"; var playback_info = {}; playback_info.itemId = context.Token("%item.id%").value; playback_info.itemName = context.Token("%item.name%").value; playback_info.userName = context.Token("%username%").value; playback_info.deviceName = context.Token("%device.name%").value; playback_info.serverName = context.Token("%server.name%").value; playback_info.memo = playback_info.userName + " is playing " + playback_info.itemName + " on device " + playback_info.deviceName + " from server " + playback_info.serverName; ScripterX.Web.Post(api_url, JSON.stringify(playback_info)); } - Once you've created your Package zip file for distribution, you can install it on your Emby server by using the Emby Scripter-X package installer interface, as shown below: - While you're testing your package, you don't have to keep uninstalling and reinstalling your package to test and debug. Simply install your package ONCE, then navigate to your Emby data directory, find ScripterX, then find Packages, then find the folder labelled with your package's assigned installationId. Inside this directory, you'll notice Package.js. Make changes directly to this file, then go back into your Emby administration panel and click the 'Reload' icon next to your package listed in your 'Installed Packages' panel. The reload icon is next to the uninstall/delete icon. If you wish to uninstall a package, simply click the trashbin, then confirm by clicking 'Really Uninstall?' There is MUCH, MUCH more to come, but for now this will get people going. There are other function groups that I am going to implement including Library searching and Item manipulation, User manipulation and searching, among many, many other functionality. Please enjoy, and as always, any comments, feedback, suggestions are MUCH MUCH appreciated. Emby ScripterX (github: https://github.com/AnthonyMusgrove/Emby-ScripterX) Project/Product Website: https://www.emby-scripterx.info/ Version v2.3.4 now up on the Emby Plugin Catalog & GitHub with changes. Events supported: On Authentication Failed, On Authentication Success, On Playback Start, On Playback Stopped, On Session Started, On Session Ended, On Media Item Added, On Media Item Updated, On Media Item Removed, on Scripter-X Scheduled Task, on Library Scan Completed, On Camera Image Uploaded, on Live TV Recording Start, on Live TV Recording Ended, onScheduledTaskStart, onScheduledTaskEnded, onPlaybackProgress, onMediaItemAddedComplete For tokens available, please see GitHub readme, or check out the Actions interface in the plugin - you can find the plugin in the Emby Server Catalog, under 'General'. ChangeLog Changes for 2.3.4: Major core rewrite Added conditions (drag and drop) Rewrote token parser and added contexts Added event onPlaybackProgress (which supports transcoding detection) Added event onMediaItemAddedComplete which is called virtually, after an onMediaItemAdded + Meta Data (or timeout of 40 seconds, whichever comes first) Added IP address tokens for Authentication events Various other modifications and changes Changes for 2.3.1: %item.library.name%, %item.library.type% issue resolved Added confirmation on delete for actions (theme friendly) Remove 'Global Tokens' section in Actions interface (they're listed now for each event) Changes for 2.3.0: Variables are now case-insensitive, refactoring a lot of the interface code (Prototype-to-production), cleaning interface, addressed various GitHub issues. Changes for 2.2.9: Progressively from v2.2.6, functionality to enable or disable events individually, many more tokens (please see GitHub tokens list or the Actions interface), global tokens (server version, uptime, etc), more item tokens (for example, season number, episode number, item meta (imdb id, tmdb id, whatever you wish), season meta, series meta, plus plenty more! Changes for 2.2.5: Aesthetics on Actions Interface (enlarged textboxes for script and interpreter, better alignment of add buttons) Changes for 2.2.4: Progessively from v2.2.0 to v2.2.4, integration with a sortable library, actions user interface customisation and remembering custom order within browser local storage. Changes for 2.2.0: Now theme friendly and compatible, changes with theme selection correctly. Changes for 2.1.9: Redesign Events/Actions interface for less clutter Please ignore the 'Advanced' tab, It won't be there in the next catalog release, its just used for debug at this stage. Changes for 2.1.7, 2.1.6, 2.1.5, 2.1.4: Progressive changes to implement Live TV Recording Events. 'Emby Scripter-X DVR Manager' was implemented in the codebase to handle all Live TV events, tokens and logging. Changes for 2.1.3: Addressed bug with %item.library.*% tokens with respect to onItemRemoved event. (see https://github.com/AnthonyMusgrove/Emby-ScripterX/issues/2 for info!) Changes for 2.1.2: Added new event - onCameraImageUploaded. This event is triggered when a user uploads an image to the Emby Server via the 'Camera Upload' functionality within the various Emby Apps. Tokens supported are as above. Below is an image of the event on the Actions page, along with an image of a sample batch script and output: Changes for 2.1.1: Actions now utilises the entire available interface space; so editing and viewing are much easier. Some input validation added for Interpreter and Script Some cosmetic modifications :- on adding new action, delete/trash button is now changed to 'X' so it indicates 'remove this unsaved action'. Once a new action is saved, the 'X' icon will change to a 'trash/delete' icon, signifying 'delete this action from the server'. Changes for 2.1.0: Bug fix for " in script name, parameters, interpreter. various other bugs, interface bug fixes very stable at this stage. Changes for 2.0.0: Redesign Interfaces, add Actions interface, Community interface (as tabs) Redesign core Allow multiple script actions for each event Changes for 1.0.0.8 - Various updates/changes: Addressed issues with having to supply entire path to interpreter. Implemented better way to detect OS platform (IsWindows() IsLinux() IsOSX()) Powershell.exe, cmd.exe, /bin/bash or a custom executable is now supported Examples now: using powershell.exe as interpreter: -File "D:\embyscripts\ScripterX-test.ps1" -Name %item.name% -ID %item.id% -Type %item.type% -LibName %item.library.name% using cmd.exe as interpreter: /s /c D:\embyscripts\test.bat AuthFail %username% %user.id% %device.id% %device.name% using /bin/bash /home/medius/scripts/test.sh AuthOK %username% Changes for 1.0.0.7: on Library Scan Completed : D:\embyscripts\test.bat Library Scan Complete! Library Scan Complete! Changes for 1.0.0.6: %item.update.reason% : Media Item Updated "1917" "D:\Media\Movies\1917.2019.1080p.BluRay.x264.AAC5.1-[YTS.MX] - Copy.mp4" (Update Reason: MetadataEdit) D:\embyscripts\test.bat Media Item Updated "%item.name%" "%item.path%" (Update Reason: %item.update.reason%) 1.0.0.5 additions: %series.id%, %series.name%, %season.id%, %season.name% : PlaybackStart ItemID: 593 - Name: "Brian: Portrait of a Dog" - Path: "D:\Media\TV\Family Guy\S01\S01E07 - Brian - Portrait Of A Dog.avi" - Username: Anthony - DeviceName: Firefox - ItemType: item type: Episode - LibraryName: TV - LibraryContentType: tvshows (seriesname: Family Guy) (season: Season 1) D:\embyscripts\test.bat PlaybackStart ItemID: %item.id% - Name: "%item.name%" - Path: "%item.path%" - Username: %username% - DeviceName: %device.name% - ItemType: item type: %item.type% - LibraryName: %item.library.name% - LibraryContentType: %item.library.type% (seriesname: %series.name%) (season: %season.name%) README is on Github. Comments/Feedback/Suggestions are GREATLY appreciated. On Scheduled Task: A field now exists to specify a script to run as a scheduled task - you'll now see under 'Scheduled Tasks -> Application' an Emby ScripterX Scheduled Task. No tokens are yet available to this field - need feedback/suggestions/comments on what should be available to specify as parameters/tokens.
- 736 replies
-
- 16
-
Several times it has happened that I have done something (like moving my library around) that has caused items to be removed from my playlists to the point that it bugged me enough to write the following BASH script. What this does is to write out a VERY PRIMITIVE html file for each playlist on the server that the defined user has access to. It also creates an even more PRIMITIVE index file, with the current timestamp as its file name, with each of the playlists hyperlinked in it. In each playlist file, the name of each item on the list is written, and it's hyperlinked to the page on the Emby server for that item. Makes it real handy when you want more info about a particular item on the playlist. This also includes the overview of each item which solves another aggravation of mine which is not being able to see the overview in the playlist unless you go in and edit the metadata. I would point out, the script has to run under an OS that supports BASH and other common linux utilities, HOWEVER, the server can run on any system Emby supports. I'm running this on my linux machine to access the playlists from my Windows server. If you don't have such an OS running, I highly recommend, at the very least, getting cygwin, but preferably grab the FREE Windows version of VM Player and install a linux distro on it (I personally prefer Debian <g>). Also, this script relies heavily on JQ (https://stedolan.github.io/jq/download/) to parse the JSON data from the Emby server so if you don't have it installed already, you will need to do that first. Other than that, this script is VERY simple. Just set the 4 variables at the top and your good to go. If you use this, please let me know. Down the road, I might add more to it if there's a desire for it. One thought I'm toying with now is to zip up a week's worth of backups for archival reasons. Of course, if I did this, would likely also just add the option of deleting old ones, but we'll see down the road. As a final note, I've only tried this on playlists with movies and TV shows in them. No idea how it would handle with music or other such lists. save_playlist.sh
-
Make API Requests for Library Scan and More in PowerShell - Help
Oracle posted a topic in Developer API
Hi, all. So, I've been just slowing chipping away at this PowerShell script I run every night to sync my server with some other drives and want to make an API request to scan the Emby library and call two other requests as well (Timelord Plugins). Has anyone does this that has some code they'd be willing to share (privately or publicly) as examples? Here is my barebones script, without any of my server's info in there. Thanks! server_sync (1).ps1- 11 replies
-
- powershell
- api
-
(and 4 more)
Tagged with:
-
Looking for help running python/bash scripts on QNAP (maybe the same process on other Linux based NAS's) I have Emby running pretty much perfectly on my NAS, but my IPTV provider, provides VOD (in M3U file) which I want converted to STRM within their own library. I have seen several python/bash scripts for doing this, by my knowledge is this area is non existent. Just looking for information on the following: Where to put the script How to run the script How to run the script at preset times How to run at startup of NAS Many thanks for any help you can give me
-
For anyone like me who started off creating their library of media and and deciding at a later date that maybe they want to move the those movies into their own folders, but don't want to manually create thousands of folders, and then manually move the files, you can automate that process with PowerShell (on WIndows). Open up a PowerShell prompt and navigate to the directory with your movies being stored, in my case on a network share. cd \\unraid\media\movies Make sure this command will create a folder for every file in the directory you just navigated to. WARNING, I was lazy when I made this. This will technically create a folder for any object in the folder that has a period in the name. So, if for whatever reason, you already have folders with a period in the name, it will try to create a folder for it as well. If you already have a folder structure with periods, either don't use this or revise the command. Get-ChildItem | Where-Object {$_.Name -Like "*.*"} | Select BaseName | ForEach-Object {New-Item -Name $_.BaseName -ItemType "Directory"} This next command will actually move every item with a period in the name, into a folder of the same name, minus the file extension. So, if you have multiple copies of a movie, with multiple resolutions, or if you keep your metadata in NFO files, ALL of those files will be moved into the same folder. Get-ChildItem | Where-Object {$_.Name -Like "*.*"} | ForEach-Object {Move-Item $_.Name $_.BaseName}
- 10 replies
-
- 1
-
- powershell
- windows
- (and 9 more)
-
A Powershell script intended to be invoked by ScripterX to log media add events on Social Media. Aggregates related media events into single posts (eg episodes rolled up to seasons, seasons to series, multiple episodes to a single post, multiple seasons to a single post) Posts JSON to a web hook Options to alter the aggregation behaviour to personal preference. Was originally designed for Integromat Web Hook. (free for 1000 per month) Has been used with a Facebook group and Android Push Notifications. Could be developed to make the message structure a bit more versatile for other services / more user friendly editing. Feature Requests Welcome. This is a learning opportunity for scripting for me, so advice welcome on how to make code more elegant. Also intended as a stop gap as media aggregation may be built into ScripterX in future.
-
Hi, I would like to group my movies with different multi-version quality unfortunately functionality doesn't work with multidirectory library. I know manual method: multi-select content and next "group versions". The most convenient method for me is to use a script for this. I can write a script, but I need a description of the structure of the database, which unfortunately I can't see anywhere. Can somebody explain me relation of sql data in sqlite db for multiversion video? Maybe there is some documentation describing the sql structure?
-
Original source Unix.stackexchange.com Thx to Adrian for this amazing script Since Emby doesnt have a proper scraper this will help to "fix" that Files to be renamed are all of the form [<tag>] <name> - <serial> [<quality>].mkv. Each anime has a lookup file called <name>.lst, listing the episodes in serial order, e.g. One Piece.lst contains: S01E01 S01E02 ... S01E08 S02E01 ... You use a bash shell at version 4 (minimum). #!/bin/bash # USAGE: canon_vids <dir> ... # Canonicalize the filenames of all MKV vids in each <dir> # All the anime lookup tables are in the lookup subdirectory # where canon_vids is stored lookup_dir="$(dirname "$0")/lookup" log_skip() { echo "SKIP ($1): $2" } find "$@" -name \*.mkv | while read f; do # Check filename against our desired pattern # (We don't want to rename what's already been renamed!) if [[ $f =~ /(\[[^]]+\])\ (.*)\ -\ ([0-9]+)\ (\[[^]]+\].mkv) ]]; then # We've now split our filename into: prefix="${BASH_REMATCH[1]}" name="${BASH_REMATCH[2]}" serial="${BASH_REMATCH[3]##0}" suffix="${BASH_REMATCH[4]}" # Some sanity checks if (( serial <= 0 )); then log_skip "$f" "Invalid serial# '$serial' for $name"; continue fi # Let's look up the episode episode="$(sed -n ${serial}p "$lookup_dir/${name}.lst")" if [[ -z "$episode" ]]; then log_skip "$f" "Can't find serial# '$serial' for $name"; continue fi mv -vn "$f" "${f%/*}/${prefix} ${name} - ${episode} ${suffix}" fi done And here's a bonus script that generates those lookup files, given the number of episodes in each season: #!/bin/bash # USAGE: generate_series <#eps> ... while [[ $1 ]]; do ((s++)) for e in $(seq "$1"); do printf "S%02dE%02d\n" $s $e done shift done Example: $ ls canon_vids generate_series # Create One Piece lookup table $ mkdir lookup $ ./generate_series 8 22 17 13 9 22 39 13 52 31 99 56 100 35 62 49 118 33 96 > lookup/One\ Piece.lst $ tail -n lookup/One\ Piece.lst S19E92 S19E93 S19E94 S19E95 S19E96 $ wc -l lookup/One\ Piece.lst 874 lookup/One Piece.lst # Create fake One Piece MKVs (adding a couple more to trigger errors) $ mkdir op $ for i in $(seq 0 876); do touch "$(printf "op/[TAG] One Piece - %02d [quality].mkv" $i)"; done $ ls op | wc -l 877 # And now, the moment of truth... $ ./canon_vids op renamed 'op/[TAG] One Piece - 724 [quality].mkv' -> 'op/[TAG] One Piece - S17E97 [quality].mkv' renamed 'op/[TAG] One Piece - 86 [quality].mkv' -> 'op/[TAG] One Piece - S06E17 [quality].mkv' ... renamed 'op/[TAG] One Piece - 819 [quality].mkv' -> 'op/[TAG] One Piece - S19E41 [quality].mkv' SKIP (op/[TAG] One Piece - 00 [quality].mkv): Invalid serial# '0' for One Piece renamed 'op/[TAG] One Piece - 52 [quality].mkv' -> 'op/[TAG] One Piece - S04E05 [quality].mkv' ... renamed 'op/[TAG] One Piece - 865 [quality].mkv' -> 'op/[TAG] One Piece - S19E87 [quality].mkv' SKIP (op/[TAG] One Piece - 875 [quality].mkv): Can't find serial# '875' for One Piece renamed 'op/[TAG] One Piece - 295 [quality].mkv' -> 'op/[TAG] One Piece - S11E69 [quality].mkv' ... renamed 'op/[TAG] One Piece - 430 [quality].mkv' -> 'op/[TAG] One Piece - S13E49 [quality].mkv' SKIP (op/[TAG] One Piece - 876 [quality].mkv): Can't find serial# '876' for One Piece renamed 'op/[TAG] One Piece - 655 [quality].mkv' -> 'op/[TAG] One Piece - S17E28 [quality].mkv' ... renamed 'op/[TAG] One Piece - 93 [quality].mkv' -> 'op/[TAG] One Piece - S07E02 [quality].mkv' renamed 'op/[TAG] One Piece - 278 [quality].mkv' -> 'op/[TAG] One Piece - S11E52 [quality].mkv' # OK, but what happens when we run it again? Will our files be further renamed? Will Luffy find One Piece? $ ./canon_vids op SKIP (op/[TAG] One Piece - 00 [quality].mkv): Invalid serial# '0' for One Piece SKIP (op/[TAG] One Piece - 875 [quality].mkv): Can't find serial# '875' for One Piece SKIP (op/[TAG] One Piece - 876 [quality].mkv): Can't find serial# '876' for One Piece # Of course! Those files were never found in the lookup table, so they're still # candidates for renaming. More importantly, no other files were touched. Little explanation: ./generate_series 8 22 17 13 9 22 39 13 52 31 99 56 100 35 62 49 118 33 96 > lookup/One\ Piece.lst Extra: If u want to automate create a line at crontab. canon_vids.txt generate_series.txt
-
This project is being abandoned in favor of Wolveix's. https://github.com/Wolveix/Plexus Please visit his project to see any future work. Hello, I’m working on a little project to iterate through my NAS and convert all files that are not easily direct played through my Roku. I’m posting it’s Github page here, in case it is of use to anyone else. I’m very open to input, commits, suggestions, etc. I’d love for this to be useful to the community. https://github.com/gorgarp/BatchConverter/
-
Hi Emby users. so I read in a post somewhere (suggestion I belive) that they wish they could scroll through a list of their movies ordered randomly so that they could "discover" movies easier. So I wrote a script that hijacks the recently added feed on the home screen to essentially use it as a dicoverability feed that will change the movies in this feed once a day (if you set it up on a scheduler that is). by default when run it will put the 3 most recently released movies in the front of the "recently added" feed followed by an old but gold movie, a hidden gem and a completely random movie. the order and quantity from each category can of course be changed. It accomplish this through editing the <dateadded> tag in the .nfo file for each movie. So if the metadata in that tag is valuable to you then this script is not for you. But personally, I couldn't care less about that metadata field. You'll need to have all of your movie folders in the same directory for this script to work though. As a Plex user I had a similar script for Plex so it didn't take very long to make a similar script that would work on Emby (although heavily refactored). it's fairly customizable as it is but if you have any feature suggestions just post it here or on the Issues github page and I'll take a look at it. for more information go to the Github page: https://github.com/KBlixt/Emhanced PS: I'm not sure, but I guess that this would suit better as a plug-in, but since I don't know even where to begin to convert it into a plugin I'll just leave it as a script. If anyone could give me any help with converting it to a plug-in then that would be awesome. ( I only know python/java but I'm not afraid to learn new stuff)
-
Hi all, I have a router running latest Advanced tomato firmware and PIA VPN running on it. I would like to run a script to enable Port Forwarding to the Port PIA provides me so I can access the Emby server remotely. However after searching the internet I am still no clearer on how to achieve this. Any help would be very much appreciated. Thanks
- 2 replies
-
- port forward
- tomato
-
(and 4 more)
Tagged with:
-
Run custom script (e.g. python, perl, etc.) when using Emby Theater
jdotero posted a topic in Windows & Xbox
Hello, Is there a way to run a custom script when using emby theater / cinema mode? In short, I would like the script to dim my lights (run an Insteon scene) when using emby theater and when the main feature beings. Ideally the script would allow the "previews" to first play, then the "custom intro", then the script executes as the main feature starts. 1) Cinema Mode Trailers (x2) <-- do nothing; wait 2) Custom Intro trailer (x1) <-- do nothing; wait 3) Main Feature <-- execute script Ideally emby would also be able to pass some environmental information (i.e. connected client and device) to the script when it is called. For example, I would only want this script to run iff user == x && client == y. (I don't need the lights to dim [or turn on] if I am watching from my laptop remotely or in a different room.) Writing the python or perl script would be quite trivial as I already know how to interface that with my home lighting system. I just want theater mode / cinema mode to trigger that script and pass the proper variables at the correct time (after trailers and custom intro, but before main feature.) A current workaround may be to use prowl (or some other message server) and watch for events. If the events are detailed enough, I can pattern to find the client and device, and match do detect when the the main feature starts and then execute the python script, but this is not as elegant as it may take a different machine to watch the events. Any pointers or thoughts anyone may be able to give would be most appreciated. Cheers, Jose- 4 replies
-
- script
- emby theater
-
(and 1 more)
Tagged with:
-
I wanted to populate my library with a local trailer for each film. I was also interested in learning a bit of Python. So this resulted in the script below, if you want to run it you'll need to install Requests and PyTube (can be done using PIP): import sys import requests import urllib import json import ConfigParser import glob import os from pytube import YouTube config = ConfigParser.RawConfigParser() config.read('trailers.ini') embyapi = "" embykey = "" embyusr = "" h = 0 i = 0 j = 0 k = 0 if config.has_option('emby', 'api'): embyapi = config.get('emby', 'api') else: embyerror = "No Emby URL in Config File.\n" if config.has_option('emby', 'key'): embykey = config.get('emby', 'key') else: embyerror += "No Emby API Key in Config File.\n" if config.has_option('emby', 'usr'): embyusr = config.get('emby', 'usr') else: embyerror += "No Emby User ID in Config File." if config.has_option('emby', 'dirfrom'): embydirf = config.get('emby', 'dirfrom') else: embydirf = "" if config.has_option('emby', 'dirto'): embydirt = config.get('emby', 'dirto') else: embydirt = "" if len(embyapi) == 0 or len(embykey) == 0 or len(embyusr) == 0: print(embyerror) sys.exit() if embyapi[-1] != "/": embyapi += "/" url = embyapi + "Users/%s/Items?IncludeItemTypes=Movie&Recursive=true&StartIndex=0&format=json&fields=RemoteTrailers,Path" % (embyusr) headers = { 'content-type': 'application/json', 'Authorization': 'MediaBrowser', 'UserId': embyusr, 'Client': 'EmbyTrailers', 'Device': 'Python Script', 'DeviceId': 'xxx', 'Version': '1.0.0.0', 'X-MediaBrowser-Token': embykey, } emby = requests.get(url, headers = headers) films = json.loads(emby.content) if not 'Name' in films['Items'][0]: print print("No Films Found") else: for film in films['Items']: if film['LocalTrailerCount'] == 0: h += 1 fulpath = film['Path'].encode("utf-8") if embydirf != "" and embydirt != "": fulpath = fulpath.replace(embydirf, embydirt, 1) fulpath = os.path.normpath(fulpath.replace('\\', os.sep)) basefil = os.path.basename(fulpath) basedir = os.path.dirname(fulpath) trail = os.path.splitext(basefil)[0] if trail[-3:-1] == "CD": trail = trail[:-4] if basedir[-1] != os.sep: basedir += os.sep if len(glob.glob(r"%s%s%s" % (basedir, trail, "-trailer*"))) == 0: download = True i += 1 for trailer in film['RemoteTrailers']: if download: try: yt = YouTube(trailer['Url'].encode("utf-8")) yt.set_filename(trail + "-trailer") video = yt.filter('mp4')[-1] video.download(basedir) except Exception, e: print(trail + " - " + trailer['Url'].encode("utf-8") + " - " + str(e)) if len(glob.glob(r"%s%s%s" % (basedir, trail, "-trailer*"))) > 0: download = False j += 1 if download: k += 1 print("Emby thinks %s Films are Missing Trailers" % (h)) print("%s Films Actually Missing Trailers" % (i)) print("Downloaded %s Trailers" % (j)) print("Unable to Download %s Trailers" % (k)) It reads a trailer.ini file: [emby] api = https://localhost/emby/ key = 00000000000000000000000000000000 usr = 11111111111111111111111111111111 dirfrom = \\Server dirto = /mnt which contains the Emby URL, Emby Username, Emby Api Key and two keys to convert the file paths (Emby reports the file location as \\Server\Movie\Movie.avi, but when I want to run the script on the local machine I want to look at /mnt/Movie/Movie.avi) Two assumptions the script makes is that the trailers are stored as <Movie Name>-trailer.mp4 and that files that have been split over multiple discs will be <Movie Name> CD1.avi, <Movie Name> CD2.avi etc I've run the script locally on my FreeBSD server and remotely from a Windows Machine (In this instance I removed the dirfrom and dirto values) and seems to work on both. Thought this might be useful to others or for someone wanting to work with Emby in Python.
-
You have JavaScript. You need a bookmarklet. This does that. Options URL-encode reserved characters: [space], %, ", <, >, #, @, &, ? Wrap in an IIFE (anonymizing function). Minify using UglifyJS. Make sure a modern version (>= 1.7) of jQuery is available for your code. http://chriszarate.github.io/bookmarkleter/ Neat little program i found and thought i would share.
-
PowerShell script to update server when running as a service
Quicky posted a topic in General/Windows
Hi all, I've been using emby as a service for while now, and having gone through quite a few updates of the server, have always found it a bit long-winded to complete the update steps, thanks to the emby installer automatically starting the desktop app version of the server rather than the service. I've finally got round to writing a quick PowerShell script that automates it a bit more: stop the current service, download the server installer, run the installer, kill the emby app and finally start the service again. I've posted it here in case anyone's got a similar workflow to me for updating emby, and is only marginally lazier than I am: # Installer download path $downloadPath = "$env:USERPROFILE\Downloads" # Stop the emby service $service = 'Media Browser' if ((get-service -DisplayName $service).Status -eq "started") { Stop-Service -DisplayName $service } # Download installer $filename = 'setup.exe' $source = "http://mb3admin.com/downloads/release/server/$filename" $destination = $downloadPath + $fileName Invoke-WebRequest $source -OutFile $destination # Run installer & $destination | Out-Null # Kill the emby app that gets started. $emby = Get-Process -Name MediaBrowser.ServerApplication -ErrorAction SilentlyContinue while (!$emby) { # Check the app is running. Wait until it starts Sleep 5 $emby = Get-Process -Name MediaBrowser.ServerApplication -ErrorAction SilentlyContinue } Stop-Process $emby -Force Sleep 5 # Delete downloaded installer Remove-Item $destination #Restart the emby service Start-Service -DisplayName $service- 18 replies
-
- 6
-
- server
- powershell
-
(and 2 more)
Tagged with:
-
I've modified a bash file monitoring script that I found here to update the library when a file changes in the given directory. So the script sends a curl request to update the Emby library when detects a change in any file inside the given path, it also works with files inside sub-directories. Thanks also to this post for the curl request. You just have to change de path and add your Emby API key to the curl link. The script runs every minute but this can be changed in the end where the sleep command is. To run it in the background you just have to execute the command: nohup /root/watch_emby.sh >/dev/null 2>&1 & This is for all linux users who don't have Real Time Monitoring. If you also want you can change the cmd variable to execute something else than the library update. Enjoy! watch_emby.txt
-
- bash
- monitoring
-
(and 3 more)
Tagged with:
-
Hello everyone, I seem to have 2 emby processes running, one is running as root (dont want) with the correct MONO_THREADS_PER_CPU and MONO_GC_PARAMS arguments, and one running as emby user (all good) without these arguments. ps auxZ | grep emby root 784 0.0 0.0 46360 3224 ? Ss 12:59 0:00 su -s /bin/sh -c exec "$0" "$@" emby -- env MONO_THREADS_PER_CPU=250 MONO_GC_PARAMS=nursery-size=128m /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emby-server -ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe -restartpath /usr/lib/emby-server/restart.sh emby 894 2.5 4.5 1452236 370664 ? Ssl 12:59 1:43 /usr/bin/mono-sgen --optimize=all /usr/lib/emby-server/bin/MediaBrowser.Server.Mono.exe -programdata /var/lib/emby-server -ffmpeg /usr/bin/ffmpeg -ffprobe /usr/bin/ffprobe -restartpath /usr/lib/emby-server/restart.sh Is having 2 processes normal? why is one running as root? And lastly, how do I fix this if it is indeed abnormal? How do I get 1 process with the cirrect arguments running as emby user? nano /etc/systemd/system/multi-user.target.wants/emby-server.service [Unit]Description=Emby Media Server After=network.target [Service] EnvironmentFile=/etc/emby-server.conf ExecStart=/usr/bin/emby-server start Restart=on-abort TimeoutSec=20 ExecStopPost=/usr/bin/emby-server clear [Install] WantedBy=multi-user.target nano /etc/init.d/emby-server !/bin/sh### BEGIN INIT INFO # Provides: emby-server # Required-Start: $remote_fs $local_fs $network # Required-Stop: $remote_fs $local_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts instance of Emby # Description: starts instance of Emby ### END INIT INFO # chkconfig: 2345 20 80 #The above indicates that the script should be started in levels 2, 3, 4, and 5, #that its start priority should be $ # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions NAME=emby-server CONF_FILE=/etc/${NAME}.conf DEFAULT_FILE=/etc/default/${NAME} # Source Emby server default configuration . $DEFAULT_FILE # Source Emby server user configuration overrides if [ -f $CONF_FILE ]; then . $CONF_FILE else echo "${CONF_FILE} not found using default settings."; fi # Path of emby binary EMBYSERVER=/usr/bin/emby-server PIDFILE=${EMBY_PIDFILE-/var/run/emby-server.pid} case "$1" in start) log_daemon_msg "Starting $NAME daemon" if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then log_daemon_msg "apparently already running" log_end_msg 0 exit 0 fi exec $EMBYSERVER start & sleep 2 if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then log_end_msg 0 else log_end_msg 1 fi stop) log_daemon_msg "Stopping $NAME daemon" if [ ! -s $PIDFILE ] || ! kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then [ -e $PIDFILE ] && rm -rf $PIDFILE log_success_msg "apparently already stopped" log_end_msg 0 exit 0 fi PID=`cat $PIDFILE` CPIDS=$(pgrep -P $PID) sleep 2 && kill -KILL $CPIDS kill -TERM $CPIDS > /dev/null 2>&1 sleep 2 if ! kill -0 $PID > /dev/null 2>&1; then rm -rf $PIDFILE log_end_msg 0 else log_end_msg 1 fi ;; status) status_of_proc -p $PIDFILE "$EMBYSERVER" "$NAME" exit $? # notreached due to set -e ;; restart|force-reload) $0 stop || exit $? $0 start || exit $? ;; *) echo "Usage: /etc/init.d/emby-server {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac Thanks
-
Python script & Application for updating the server as a service
L.Fino posted a topic in General/Windows
Hii all Because the update process for the emby server (while it's running as a service) can be a bit annoying, so i made an application with a python script. It works no matter where it's located. You just have to unzip the *.zip file in the attachement. After that, in the unzipped folder run the "emby_update_v2.exe" as administrator. The application can be used with diffrent commandline arguments: /beta - Start normal with updating beta server, while its running as a service /dev - Start normal with updating dev server, while its running as a service /download - Start with downloading the regular version first /beta_download - Start with downloading the beta version first /dev_download - Start with downloading the dev version first /taskkill - Start with killing the process instead of stopping the service /debug - Start into the Debug Mode for debugging the functions. >> without an argument - start normal with updating the regular server, while its running as a service PLEASE NOTE: - The application normaly starts with the ability to stop the service at very first - If you know the service IS NOT running, start the application with one of the three 'download' arguments - If you have the Beta server service running, simply add the /beta argument in the commandline - If you have the Dev server service running, simply add the /dev argument in the commandline - If you have any kind of trouble, start the application with the /debug argument to try and/or debug functions Updater.zip -
I'm wondering if anybody has made their own simple script to go through (recursively) sub-directories and remove x in filnames with y. I've looked online (python) and found some pretty long winded solutions, but I feel like this could be done simply in a nested for loop with only 1 or 2 modules. for filename in dir: if filename contains ['list', 'of', 'items', 'easily', 'enumerated'] newname = filename.replace(x,y) os.rename(filename,newname) That is non recursive, but has been working for regular txt files for me, but not folders. Any suggestions?
-
Has anyone tried the init.d script on Ubuntu 14.04 yet? I don't think I have ever gotten one of these init.d scripts to work without modifications, but this new one changed a lot. And from the command prompt I just get and of course PID 3783 will not exist afterwords sudo emby-server start emby-server start/running, process 3783 This is all I get in the syslog Aug 13 13:03:13 CRACKHEADGDK /proc/self/fd/9: DEBUG: EMBYSERVER='/usr/lib/emby-server/emby-server'#012EMBY_BIN='/usr/lib/emby-server/MediaBrowser.Server.Mono.exe'#012EMBY_DATA='/var/lib/emby-server'#012EMBY_PATH='/usr/lib/emby-server'#012EMBY_PIDFILE='/var/run/emby-server.pid'#012EMBY_USER='emby'#012IFS=' #011#012'#012OPTIND='1'#012PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'#012PPID='1'#012PS1='# '#012PS2='> '#012PS4='+ '#012PWD='/'#012TERM='linux'#012UPSTART_INSTANCE=''#012UPSTART_JOB='emby-server' Aug 13 13:03:13 CRACKHEADGDK kernel: [ 2690.725826] init: emby-server main process (3719) terminated with status 127 Aug 13 13:03:13 CRACKHEADGDK kernel: [ 2690.725836] init: emby-server main process ended, respawning Aug 13 13:03:13 CRACKHEADGDK kernel: [ 2690.728713] init: emby-server post-stop process (3724) terminated with status 127
-
Hi guys, I'm looking for a way to run a script after subtitles are downloaded. Should I modify the sources, or do I have a better user-friendly solution for that? Thanks
-
Hey there so I decided I would get Media Browser not too long ago and so far it has been great when I can get WMC to work. The problem I am having right now seems simple to fix but so far it has resulted in me wasting over 3 or 4 hours to try and get the server to start on PC startup w/o logging in. Apparently this is difficult to accomplish and I really cannot understand why. I have disabled the startup on the dashboard and I don't have any startup tasks in task scheduler for the application or service turned on so I am stumped. Currently I have the service set to Automatic and I also tried Automatic (delayed start). Logon is set up as this account which has administrator priveleges and I also tried Local System Account. I also have recovery setup to restart the service each time it cannot start but that does nothing. I even added some dependencies to the service: Media Center Extender Service[Mcx2Svc], Network List Service[netprofm], and the default Server[LanmanServer} service. Some other things I tried were creating a task in task scheduler to run the actual application. I also tried running a bat/cmd file with the lines START "" "C:\Users\*******\AppData\Roaming\MediaBrowser-Server\System\MediaBrowser.ServerApplication.exe" I also tried running the script in gpedit.msc under Local Computer Policy > Windows Settings > Scripts (Startup/Shutdown) > Startup . I attempted to save it as a BAT file and a CMD file but both do nothing. Maybe I need to add more dependencies (if so what?) ? Anyways as you can tell I have exhausted google searching and forum searching so any help would be very appreciated! Thanks!
- 17 replies
-
- startup
- task scheduler
-
(and 6 more)
Tagged with:
-
Duplicate Clean Backdrops of mixed resolution and duplicates
ginjaninja posted a topic in Tools and Utilities
https://dl.dropboxusercontent.com/u/84611964/OrderBackdrops.cmd Requires mediainfo and imagemagick command line utilities Background I wanted to keep my backdrops clean of mixed resolution, non contiguous naming, and duplicate images, The script uses imagemagick to yield a comparison value to identify duplicates. Install Download mediainfo and imagemagick clis, Extract to folders of choice Download CMD file above and copy to shell:sendto edit CMD with paths to mediainfo and imagemagick and turn on/off log only Functions For each folder in path, re cursing subfolders) If low res images exist AND 1+ high res then delete low res images If duplicates exists delete duplicates rename backdrops into order - backdrop.jpg, backdrop1.jpg, backdrop2.jpg, etc creates a processed.txt in every processed folder, in case needs to be rerun...they can be easily deleted once happy Usage Test 1st before using on real folders Right click a folder eg. movie and send to the script, each separate folder is enumerated separately The threshold value should be increased/decreased if duplicates are not being detected/uniques being detected as duplicates. use imagemagick\compare -metric NCC backdrop1.jpg backdrop2.jpg null: manually from the command line to find a threshold value for comparison for use in your script Notes Backdrop order is not well respected, backdrop.jpg (the first one) shouldn't be deleted, unless it is a low res image amongst 1 or more high res images..Backdrop 11 will be ordered higher than Backdrop 2 due to batch order. As with all my scripts its very crude, im guessing as i go along. The Comparison function of image magic, could be improved upon, there may be quicker more appropriate functions and the use of a threshold could break out of comparison once its known to be different enough (for performance considerations) Temporary files could be used to compare different resolution images, but that would take even longer and would require more understanding of imag magick comparison than i have. if i could get the comparison value out of image magic without using a file, it would be more media browser change detection friendly. have tried to use identity function to compute a quick hash to weed out 100% identity quickly, however the duplicates in practise are too nuanced for this function to yield match. advice as always welcomed... The NCC comparison can deal with different jpg quality factors, but cant detect identity where there is a slight offset between the two images, or if one image is a subimage of another (would be too computationally intensive, besides the script is looking for more identical ness that that..eg same image on fanart and tmdb.. edit fixed crash when_result was not defined -
Remove Header Compression and Subtitles from selected MKVs
ginjaninja posted a topic in Tools and Utilities
Script to remove header compression and subtitles from selected MKV(s). Useful for XBOX playback in MBC/WMC Description For windows OSes with batch support Script remuxes selected file(s) into a temporary holder (.mux), deletes (default) or renames the original (.old). and renames the temporary as original so you are left with the same file(name)(s) but without compression and subs. script relies on MKVMERGE being in 'PATH' (otherwise you could hardcode the path to MKVMERGE) https://www.bunkus.org/videotools/mkvtoolnix/downloads.html Use rename (original) rather than delete in script until you are confident. Test first with files in a backup folder. Unrem the pauses if you want to see what the script is doing. Download https://www.dropbox.com/s/87sftwu0cg0lbe3/RemoveHdrSubs.bat Install Copy script to shell:sendto folder (varies dependant on OS) [Rename script filename to your preference] Use Right Click on selected file(s) and send to the script. [Alternatively place script on e.g.. desktop - to support dragging file(s) onto the script) Alternative uses. You can change the main MKVMERGE command for other common library tasks e.g.. mkvmerge.exe -o "%~dpn1.MUX" --compression -1:none -a !2 -M -S "%~1" remove the 2nd audio track (as well as turn off header compression and remove subtitles).