Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sleikang committed Sep 4, 2022
2 parents 159d0bc + 321e343 commit 7d9f592
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-build-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build EmbyChineseNameSynchronous Nightly

on:
schedule:
- cron: '0 2 * * *'

jobs:
push:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@master

- name: Set Version
id: set-version
run: |
echo "::set-output name=version::${GITHUB_REF:10}"
echo "ReleaseTag=${GITHUB_REF:10}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

-
name: Build EmbyChineseNameSynchronous
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
linux/arm/v6
push: true
build-args: |
VERSION=${{ steps.set-version.outputs.version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/embychinesenamesynchronous:nightly
59 changes: 59 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build EmbyChineseNameSynchronous

on:
release:
types: [published]

jobs:
push:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@master

- name: Set Version
id: set-version
run: |
echo "::set-output name=version::${GITHUB_REF:10}"
echo "ReleaseTag=${GITHUB_REF:10}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

-
name: Build EmbyChineseNameSynchronous
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
linux/arm/v6
push: true
build-args: |
VERSION=${{ steps.set-version.outputs.version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/embychinesenamesynchronous:${{ steps.set-version.outputs.version }}
${{ secrets.DOCKER_USERNAME }}/embychinesenamesynchronous:latest
-
name: Docker Hub Description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ddsderek/embychinesenamesynchronous
short-description: EmbyChineseNameSynchronous Image
readme-filepath: ./README_DOCKER.md
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM alpine:3.16

ENV EMBYHOST=embyhost \
EMBYUSERID=embyuserid \
EMBYKEY=embykey \
TMDBKEY=tmdbkey \
THREADNUM=16 \
UPDATEPEOPLE=True \
UPDATETIME=1 \
TZ=Asia/Shanghai

RUN apk add --update --no-cache \
python3-dev \
py3-pip \
bash \
tzdata && \
pip install zhconv && \
pip install requests && \
pip install simplejson && \
# 清理
rm -rf /tmp/* /root/.cache /var/cache/apk/*

COPY --chmod=755 . /opt

CMD [ "/opt/start.sh" ]
37 changes: 37 additions & 0 deletions README_DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
**docker-cli**

```
docker run -itd \
--name EmbyChineseNameSynchronous \
-v ./logs:/opt/logs \
-e EMBYHOST=embyhost \
-e EMBYUSERID=embyuserid \
-e EMBYKEY=embykey \
-e TMDBKEY=tmdbkey \
-e THREADNUM=16 \
-e UPDATEPEOPLE=True \
-e UPDATETIME=1 \
-e TZ=Asia/Shanghai \
ddsderek/embychinesenamesynchronous:latest
```

**docker-compose**

```
version: '3.3'
services:
embychinesenamesynchronous:
container_name: EmbyChineseNameSynchronous
volumes:
- './logs:/opt/logs'
environment:
- EMBYHOST=embyhost
- EMBYUSERID=embyuserid
- EMBYKEY=embykey
- TMDBKEY=tmdbkey
- THREADNUM=16
- UPDATEPEOPLE=True
- UPDATETIME=1
- TZ=Asia/Shanghai
image: 'ddsderek/embychinesenamesynchronous:latest'
```
52 changes: 52 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

function setting {

touch /setting.lock

mkdir -p /opt/logs
touch /opt/logs/EmbyChineseNameSynchronous.log

ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone

cat > /opt/main.py <<EOF
import time
from embyserver import embyserver
#EMBY 域名 包含http(s)和端口号后面不带/
#例如https://xxx.xxx.xxx:8920
embyhost = '$EMBYHOST'
#EMBY 用户ID 进EMBY 用户点击管理员账号配置可以在网址上看到userId
embyuserid = '$EMBYUSERID'
#EMBY APIKEY
embykey = '$EMBYKEY'
#TMDB APIKEY
tmdbkey = '$TMDBKEY'
#线程数量
threadnum = $THREADNUM
#是否刷新人名
updatepeople = $UPDATEPEOPLE
#每次刷新全部媒体间隔时间 [小时]
updatetime = $UPDATETIME
if __name__ == '__main__':
embymediaclient = embyserver(embyhost=embyhost, embyuserid=embyuserid, embykey=embykey, tmdbkey=tmdbkey, threadnum=threadnum, updatepeople=updatepeople)
while True:
try:
print('开始刷新媒体库元数据')
embymediaclient.update_media_name()
print('刷新媒体库元数据完成')
except Exception as reuslt:
print(reuslt)
EOF

}

if [ ! -f /setting.lock ]; then
setting
fi

cd /opt
python3 main.py >> /opt/logs/EmbyChineseNameSynchronous.log

0 comments on commit 7d9f592

Please sign in to comment.