Skip to content

Commit 124fad6

Browse files
authored
Merge pull request #43 from dimkroon/dev
2 parents 8fce684 + a8b62b7 commit 124fad6

1,151 files changed

Lines changed: 146 additions & 2360126 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/updater.yml

Lines changed: 91 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This is a workflow to update the repository every day at 12:00PM
1+
# This is a workflow to update the repository every day at 22:00PM
22

33
name: Updater
44

@@ -10,23 +10,98 @@ on:
1010

1111

1212
jobs:
13-
cron:
13+
update-epg-data:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v3
18-
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install pytz
23-
sudo apt-get install -y xmltv
24-
sudo apt-get install -y libmojolicious-perl
25-
26-
- name: update
27-
working-directory: scripts
28-
run: |
17+
- name: Checkout code branch
18+
uses: actions/checkout@v6
19+
20+
- name: Checkout data branch
21+
uses: actions/checkout@v6
22+
with:
23+
ref: master
24+
path: databranch
25+
26+
- name: Print folder structure
27+
run: ls -R ./
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install pytz
33+
sudo apt-get install -y xmltv
34+
sudo apt-get install -y libmojolicious-perl
35+
36+
- name: Copy raw files from data branch
37+
run: cp -rf databranch/raw ./
38+
continue-on-error: true
39+
40+
- name: Print folder structure
41+
run: ls -R ./
42+
43+
- name: Update
44+
working-directory: scripts
45+
run: python3 update_all_tv_guides.py
46+
47+
- name: Print folder structure
48+
run: ls -R ./
49+
50+
- name: Store raw data
51+
uses: actions/upload-artifact@v6
52+
with:
53+
name: raw-data
54+
path: raw/
55+
retention-days: 7
56+
57+
- name: Store EPG data
58+
uses: actions/upload-artifact@v6
59+
with:
60+
name: epg-data
61+
path: data/
62+
retention-days: 2
63+
64+
65+
push-epg-data:
66+
needs: update-epg-data
67+
runs-on: ubuntu-latest
68+
permissions:
69+
contents: write
70+
71+
steps:
72+
- name: Checkout data branch
73+
uses: actions/checkout@v6
74+
with:
75+
ref: master
76+
77+
- name: Print folder contents after checkout
78+
run: ls -A ./
79+
80+
- name: Clean existing data
81+
run: rm -rf ./*
82+
83+
- name: Print folder contents after cleanup
84+
run: ls -A ./
85+
86+
- name: Download stored EPG data
87+
uses: actions/download-artifact@v7
88+
with:
89+
name: epg-data
90+
91+
- name: Download stored raw files
92+
uses: actions/download-artifact@v7
93+
with:
94+
name: raw-data
95+
path: raw
96+
97+
- name: Print folder structure
98+
run: ls -R ./
99+
100+
- name: Force-push new data
101+
run: |
102+
now=$(date +"%d/%m/%Y %H:%M:%S-%Z")
29103
git config user.name 'GitHub Actions'
30104
git config user.email 'github@noreply.github.com'
31-
bash update_all_tv_guides.sh
32-
shell: bash
105+
git add --all
106+
git commit --amend -m "Auto update TV guides ($now)"
107+
git push -f origin master

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ Temporary Items
3333
__pycache__/
3434
*.py[cod]
3535
*$py.class
36+
37+
38+
/raw/
39+
cache/
40+
.cache/
41+
.local/
42+
.selected_editor
43+
.bash_history

README.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,33 @@ This repository keeps XMLTV TV guides up to date in order to be used with the Li
99

1010
## Developers notes
1111

12-
The `update_all_tv_guides.sh` can be used to automatically update TV guides files (`xxxxx.xml` files).
13-
The script automatically create a commit with the latest TV guides and it will push the modification on this GitHub repository.
14-
This script is executed every night with a cron task but you can trigger it manually on your own computer.
15-
16-
## Fonctionnement (only in french ATM)
17-
18-
* Si on est le jour J (par exemple le 19/06/2020)
19-
* Toutes les nuits, le script bash `update_all_tv_guides.sh` est exécuté
20-
* Ce que fait le script bash (`update_all_tv_guides.sh`)
21-
* Pull du dépôt GitHub
22-
* Suppression des fichiers XMLTV de la racine
23-
* Pour chaque pays, récupération du programme TV de la journée J+2 (par exemple le 21/06/2020) qu'on place dans le dossier `raw`
24-
* Appel du petit script Python (`post_treatment.py`)
25-
* Suppression, dans le dossier `raw`, des programmes TV trop anciens
26-
* Fusion, pour chaque pays, des programmes TV de chaque jour présents dans le dossier `raw`
27-
* Post traitement des programmes TV (découpage par jour, avec heure locale ou UTC, ...)
28-
* Push sur le dépôt GitHub des modifications
12+
Contrary to what the name suggests, the `master` branch is not the default
13+
branch in this repo. It contains no code, just EPG data files. The default
14+
branch is `dev`, which contains all code and no data. All PR's should target
15+
the `dev` branch.
16+
17+
The `update_all_tv_guides.py` script can be used to automatically update TV
18+
guides files (`xxxxx.xml` files). This script is executed every night from a
19+
GitHub workflow that is triggered by a cron task, but you can run it manually
20+
on your own computer. The workflow automatically create a commit with the
21+
latest TV guides and it will push the modifications to the master branch on
22+
this GitHub repository.
23+
24+
## How it works
25+
26+
* Every night at 22:00 the workflow runs.
27+
* Pull the `dev` branch from the GitHub repo.
28+
* Pull the `master` branch from the GitHub repo and copy the folder with raw
29+
files.
30+
* Python script `update_all_tv_guides.py` is executed
31+
* What the script does (`update_all_tv_guides.py`):
32+
* Delete XMLTV files from the root directory
33+
* Deletes outdated files from the `raw` folder
34+
* For each country, always retrieve the file with TV programmes for tomorrow
35+
and place it in the `raw` folder.
36+
* Determine how many days of EPG should be available for each country and
37+
retrieve the programmes for each day for which no raw file is yet available.
38+
* Calls the small Python script (`post_treatment.py`)
39+
* Merges the TV programmes for each day in the `raw` folder for each country
40+
* Post-processes the TV programmes (divides them by day, with local time or UTC, etc.)
41+
* Pushes xmltv files and raw files to the master branch of the GitHub repository

raw/.stay

Whitespace-only changes.

0 commit comments

Comments
 (0)