Skip to content

Commit

Permalink
Merge pull request #173 from luigi311/dev
Browse files Browse the repository at this point in the history
Add support for emby, add sync in progress for jellyfin and emby
  • Loading branch information
luigi311 authored Jun 3, 2024
2 parents b317530 + 21ffce6 commit 24035e2
Show file tree
Hide file tree
Showing 16 changed files with 1,690 additions and 1,046 deletions.
36 changes: 28 additions & 8 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ MAX_THREADS = 32
WHITELIST_USERS = "testuser1,testuser2"



# Plex

## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers
Expand All @@ -77,13 +76,6 @@ PLEX_TOKEN = "SuperSecretToken, SuperSecretToken2"
## Set to True if running into ssl certificate errors
SSL_BYPASS = "False"

## control the direction of syncing. e.g. SYNC_FROM_PLEX_TO_JELLYFIN set to true will cause the updates from plex
## to be updated in jellyfin. SYNC_FROM_PLEX_TO_PLEX set to true will sync updates between multiple plex servers
SYNC_FROM_PLEX_TO_JELLYFIN = "True"
SYNC_FROM_JELLYFIN_TO_PLEX = "True"
SYNC_FROM_PLEX_TO_PLEX = "True"
SYNC_FROM_JELLYFIN_TO_JELLYFIN = "True"


# Jellyfin

Expand All @@ -94,3 +86,31 @@ JELLYFIN_BASEURL = "http://localhost:8096, http://nas:8096"
## Jellyfin api token, created manually by logging in to the jellyfin server admin dashboard and creating an api key
## Comma separated list for multiple servers
JELLYFIN_TOKEN = "SuperSecretToken, SuperSecretToken2"


# Emby

## Emby server URL, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers
EMBY_BASEURL = "http://localhost:8097"

## Emby api token, created manually by logging in to the Emby server admin dashboard and creating an api key
## Comma seperated list for multiple servers
EMBY_TOKEN = "ed9507cba8d14d469ae4d58e33afc515"


# Syncing Options

## control the direction of syncing. e.g. SYNC_FROM_PLEX_TO_JELLYFIN set to true will cause the updates from plex
## to be updated in jellyfin. SYNC_FROM_PLEX_TO_PLEX set to true will sync updates between multiple plex servers
SYNC_FROM_PLEX_TO_JELLYFIN = "True"
SYNC_FROM_PLEX_TO_PLEX = "True"
SYNC_FROM_PLEX_TO_EMBY = "True"

SYNC_FROM_JELLYFIN_TO_PLEX = "True"
SYNC_FROM_JELLYFIN_TO_JELLYFIN = "True"
SYNC_FROM_JELLYFIN_TO_EMBY = "True"

SYNC_FROM_EMBY_TO_PLEX = "True"
SYNC_FROM_EMBY_TO_JELLYFIN = "True"
SYNC_FROM_EMBY_TO_EMBY = "True"
68 changes: 46 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,43 +40,67 @@ jobs:

- name: "Start containers"
run: |
export PGID=$(id -g)
export PUID=$(id -u)
JellyPlex-Watched-CI/start_containers.sh
sudo chown -R $PUID:$PGID JellyPlex-Watched-CI
docker pull lscr.io/linuxserver/plex &
docker pull lscr.io/linuxserver/jellyfin &
wait
docker-compose -f JellyPlex-Watched-CI/plex/docker-compose.yml up -d
docker-compose -f JellyPlex-Watched-CI/jellyfin/docker-compose.yml up -d
# Wait for containers to start
sleep 10
docker-compose -f JellyPlex-Watched-CI/plex/docker-compose.yml logs
docker-compose -f JellyPlex-Watched-CI/jellyfin/docker-compose.yml logs
for FOLDER in $(find "JellyPlex-Watched-CI" -type f -name "docker-compose.yml" -exec dirname {} \;); do
docker-compose -f "${FOLDER}/docker-compose.yml" logs
done
- name: "Run tests"
- name: "Test Plex"
run: |
mv test/ci_plex.env .env
python main.py
python test/validate_ci_marklog.py --plex
rm mark.log
- name: "Test Jellyfin"
run: |
mv test/ci_jellyfin.env .env
python main.py
python test/validate_ci_marklog.py --jellyfin
rm mark.log
- name: "Test Emby"
run: |
# Test ci1
mv test/ci1.env .env
mv test/ci_emby.env .env
python main.py
python test/validate_ci_marklog.py --emby
rm mark.log
# Test ci2
mv test/ci2.env .env
- name: "Test Guids"
run: |
mv test/ci_guids.env .env
python main.py
python test/validate_ci_marklog.py --dry
rm mark.log
# Test ci3
mv test/ci3.env .env
- name: "Test Locations"
run: |
mv test/ci_locations.env .env
python main.py
python test/validate_ci_marklog.py --dry
rm mark.log
- name: "Test writing to the servers"
run: |
# Test writing to the servers
mv test/ci_write.env .env
python main.py
# Test again to test if it can handle existing data
python main.py
cat mark.log
python test/validate_ci_marklog.py
python test/validate_ci_marklog.py --write
rm mark.log
docker:
runs-on: ubuntu-latest
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/26b47c5db63942f28f02f207f692dc85)](https://www.codacy.com/gh/luigi311/JellyPlex-Watched/dashboard?utm_source=github.com\&utm_medium=referral\&utm_content=luigi311/JellyPlex-Watched\&utm_campaign=Badge_Grade)

Sync watched between jellyfin and plex locally
Sync watched between jellyfin, plex and emby locally

## Description

Keep in sync all your users watched history between jellyfin and plex servers locally. This uses file names and provider ids to find the correct episode/movie between the two. This is not perfect but it works for most cases. You can use this for as many servers as you want by entering multiple options in the .env plex/jellyfin section separated by commas.
Keep in sync all your users watched history between jellyfin, plex and emby servers locally. This uses file names and provider ids to find the correct episode/movie between the two. This is not perfect but it works for most cases. You can use this for as many servers as you want by entering multiple options in the .env plex/jellyfin section separated by commas.

## Features

Expand All @@ -28,17 +28,17 @@ Keep in sync all your users watched history between jellyfin and plex servers lo
* \[x] Use single login
* \[x] One way/multi way sync
* \[x] Sync watched
* \[ ] Sync in progress
* \[x] Sync in progress

### Emby

* \[ ] Match via filenames
* \[ ] Match via provider ids
* \[ ] Map usernames
* \[ ] Use single login
* \[ ] One way/multi way sync
* \[ ] Sync watched
* \[ ] Sync in progress
* \[x] Match via filenames
* \[x] Match via provider ids
* \[x] Map usernames
* \[x] Use single login
* \[x] One way/multi way sync
* \[x] Sync watched
* \[x] Sync in progress

## Configuration

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PlexAPI==4.15.7
requests==2.31.0
requests==2.32.0
python-dotenv==1.0.0
21 changes: 21 additions & 0 deletions src/emby.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from src.jellyfin_emby import JellyfinEmby


class Emby(JellyfinEmby):
def __init__(self, baseurl, token):
authorization = (
"Emby , "
'Client="JellyPlex-Watched", '
'Device="script", '
'DeviceId="script", '
'Version="0.0.0"'
)
headers = {
"Accept": "application/json",
"X-Emby-Token": token,
"X-Emby-Authorization": authorization,
}

super().__init__(
server_type="Emby", baseurl=baseurl, token=token, headers=headers
)
Loading

0 comments on commit 24035e2

Please sign in to comment.