mirror of
https://github.com/iptv-org/database.git
synced 2024-11-21 18:42:31 -05:00
Merge branch 'request-processing-automation'
This commit is contained in:
commit
ff32e337ef
5 changed files with 515 additions and 2 deletions
39
.github/workflows/update.yml
vendored
Normal file
39
.github/workflows/update.yml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
name: update
|
||||
on:
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: tibdex/github-app-token@v1
|
||||
id: create-app-token
|
||||
with:
|
||||
app_id: ${{ secrets.APP_ID }}
|
||||
private_key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||
- run: npm install
|
||||
- run: GITHUB_TOKEN=${{ steps.create-app-token.outputs.token }} npm run db:update --silent >> $GITHUB_OUTPUT
|
||||
id: issue-process
|
||||
- name: Commit Changes
|
||||
run: |
|
||||
git config user.name ${{ github.actor }}
|
||||
git config user.email '${{ github.actor }}@users.noreply.github.com'
|
||||
git add data/channels.csv
|
||||
git commit -m "[Bot] Update channels.csv"
|
||||
git status
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ steps.create-app-token.outputs.token }}
|
||||
branch: bot/auto-update
|
||||
branch-suffix: timestamp
|
||||
delete-branch: true
|
||||
add-paths: |
|
||||
data/*.csv
|
||||
title: '[Bot] Update database'
|
||||
body: |
|
||||
This pull request is created by [update][1] workflow.
|
||||
|
||||
${{ steps.issue-process.outputs.OUTPUT }}
|
||||
|
||||
[1]: https://github.com/iptv-org/database/actions/runs/${{ github.run_id }}
|
241
package-lock.json
generated
241
package-lock.json
generated
|
@ -7,6 +7,8 @@
|
|||
"name": "@iptv-org/database",
|
||||
"dependencies": {
|
||||
"@joi/date": "^2.1.0",
|
||||
"@octokit/core": "^4.2.0",
|
||||
"@octokit/plugin-paginate-rest": "^6.0.0",
|
||||
"autocrop-js": "^0.2.0",
|
||||
"axios": "^0.25.0",
|
||||
"chalk": "^4.1.2",
|
||||
|
@ -156,6 +158,116 @@
|
|||
"moment": "2.x.x"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/auth-token": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.3.tgz",
|
||||
"integrity": "sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^9.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/core": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-4.2.0.tgz",
|
||||
"integrity": "sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg==",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^3.0.0",
|
||||
"@octokit/graphql": "^5.0.0",
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/request-error": "^3.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/endpoint": {
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-7.0.5.tgz",
|
||||
"integrity": "sha512-LG4o4HMY1Xoaec87IqQ41TQ+glvIeTKqfjkCEmt5AIwDZJwQeVZFIEYXrYY6yLwK+pAScb9Gj4q+Nz2qSw1roA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^9.0.0",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/graphql": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-5.0.5.tgz",
|
||||
"integrity": "sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ==",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/openapi-types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-16.0.0.tgz",
|
||||
"integrity": "sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA=="
|
||||
},
|
||||
"node_modules/@octokit/plugin-paginate-rest": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.0.0.tgz",
|
||||
"integrity": "sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^9.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request": {
|
||||
"version": "6.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-6.2.3.tgz",
|
||||
"integrity": "sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA==",
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^7.0.0",
|
||||
"@octokit/request-error": "^3.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request-error": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-3.0.3.tgz",
|
||||
"integrity": "sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^9.0.0",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/types": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-9.0.0.tgz",
|
||||
"integrity": "sha512-LUewfj94xCMH2rbD5YJ+6AQ4AVjFYTgpp6rboWM5T7N3IsIF65SBEOVcYMGAEzO/kKNiNaW4LoWtoThOhH06gw==",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sideway/address": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.3.tgz",
|
||||
|
@ -281,6 +393,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"node_modules/before-after-hook": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
||||
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
||||
},
|
||||
"node_modules/bl": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
||||
|
@ -713,6 +830,11 @@
|
|||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/deprecation": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
||||
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
},
|
||||
"node_modules/detect-libc": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz",
|
||||
|
@ -1286,6 +1408,14 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
|
@ -2857,6 +2987,11 @@
|
|||
"resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz",
|
||||
"integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA=="
|
||||
},
|
||||
"node_modules/universal-user-agent": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
@ -3115,6 +3250,92 @@
|
|||
"moment": "2.x.x"
|
||||
}
|
||||
},
|
||||
"@octokit/auth-token": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.3.tgz",
|
||||
"integrity": "sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA==",
|
||||
"requires": {
|
||||
"@octokit/types": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/core": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-4.2.0.tgz",
|
||||
"integrity": "sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg==",
|
||||
"requires": {
|
||||
"@octokit/auth-token": "^3.0.0",
|
||||
"@octokit/graphql": "^5.0.0",
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/request-error": "^3.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/endpoint": {
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-7.0.5.tgz",
|
||||
"integrity": "sha512-LG4o4HMY1Xoaec87IqQ41TQ+glvIeTKqfjkCEmt5AIwDZJwQeVZFIEYXrYY6yLwK+pAScb9Gj4q+Nz2qSw1roA==",
|
||||
"requires": {
|
||||
"@octokit/types": "^9.0.0",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/graphql": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-5.0.5.tgz",
|
||||
"integrity": "sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ==",
|
||||
"requires": {
|
||||
"@octokit/request": "^6.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/openapi-types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-16.0.0.tgz",
|
||||
"integrity": "sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA=="
|
||||
},
|
||||
"@octokit/plugin-paginate-rest": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.0.0.tgz",
|
||||
"integrity": "sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw==",
|
||||
"requires": {
|
||||
"@octokit/types": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/request": {
|
||||
"version": "6.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-6.2.3.tgz",
|
||||
"integrity": "sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA==",
|
||||
"requires": {
|
||||
"@octokit/endpoint": "^7.0.0",
|
||||
"@octokit/request-error": "^3.0.0",
|
||||
"@octokit/types": "^9.0.0",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/request-error": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-3.0.3.tgz",
|
||||
"integrity": "sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ==",
|
||||
"requires": {
|
||||
"@octokit/types": "^9.0.0",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"@octokit/types": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-9.0.0.tgz",
|
||||
"integrity": "sha512-LUewfj94xCMH2rbD5YJ+6AQ4AVjFYTgpp6rboWM5T7N3IsIF65SBEOVcYMGAEzO/kKNiNaW4LoWtoThOhH06gw==",
|
||||
"requires": {
|
||||
"@octokit/openapi-types": "^16.0.0"
|
||||
}
|
||||
},
|
||||
"@sideway/address": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.3.tgz",
|
||||
|
@ -3211,6 +3432,11 @@
|
|||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"before-after-hook": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
||||
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
||||
},
|
||||
"bl": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
||||
|
@ -3538,6 +3764,11 @@
|
|||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
|
||||
},
|
||||
"deprecation": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
||||
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
},
|
||||
"detect-libc": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz",
|
||||
|
@ -3969,6 +4200,11 @@
|
|||
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
|
||||
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
|
||||
},
|
||||
"is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
|
@ -5227,6 +5463,11 @@
|
|||
"resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz",
|
||||
"integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA=="
|
||||
},
|
||||
"universal-user-agent": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"act:check": "act pull_request -W .github/workflows/check.yml",
|
||||
"act:deploy": "act push -W .github/workflows/deploy.yml",
|
||||
"db:validate": "node scripts/db/validate.js",
|
||||
"db:export": "node scripts/db/export.js"
|
||||
"db:export": "node scripts/db/export.js",
|
||||
"db:update": "node scripts/db/update.js"
|
||||
},
|
||||
"pre-commit": [
|
||||
"db:validate"
|
||||
|
@ -13,6 +14,8 @@
|
|||
"author": "Arhey",
|
||||
"dependencies": {
|
||||
"@joi/date": "^2.1.0",
|
||||
"@octokit/core": "^4.2.0",
|
||||
"@octokit/plugin-paginate-rest": "^6.0.0",
|
||||
"autocrop-js": "^0.2.0",
|
||||
"axios": "^0.25.0",
|
||||
"chalk": "^4.1.2",
|
||||
|
|
132
scripts/db/update.js
Normal file
132
scripts/db/update.js
Normal file
|
@ -0,0 +1,132 @@
|
|||
const { csv, file } = require('../core')
|
||||
const channelScheme = require('../db/schemes/channels')
|
||||
const { Octokit } = require('@octokit/core')
|
||||
const { paginateRest } = require('@octokit/plugin-paginate-rest')
|
||||
const CustomOctokit = Octokit.plugin(paginateRest)
|
||||
const _ = require('lodash')
|
||||
|
||||
const octokit = new CustomOctokit({
|
||||
auth: process.env.GITHUB_TOKEN
|
||||
})
|
||||
|
||||
const DATA_DIR = process.env.DATA_DIR || './data'
|
||||
const OWNER = 'iptv-org'
|
||||
const REPO = 'database'
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const filepath = `${DATA_DIR}/channels.csv`
|
||||
let channels = await csv.fromFile(filepath)
|
||||
const issues = await fetchIssues('channels:add,approved')
|
||||
const processedIssues = []
|
||||
issues.map(parseIssue).forEach(({ issue, channel }) => {
|
||||
if (!channel) {
|
||||
updateIssue(issue, { labels: ['channels:add', 'rejected:invalid'] })
|
||||
return
|
||||
}
|
||||
|
||||
const found = channels.find(c => c.id === channel.id)
|
||||
if (found) {
|
||||
updateIssue(issue, { labels: ['channels:add', 'rejected:duplicate'] })
|
||||
return
|
||||
}
|
||||
|
||||
channels.push(channel)
|
||||
processedIssues.push(issue)
|
||||
})
|
||||
|
||||
channels = _.orderBy(channels, [channels => channels.id.toLowerCase()], ['asc'])
|
||||
await csv.save(filepath, channels)
|
||||
|
||||
const output = processedIssues.map(issue => `Closes #${issue.number}`).join('\r\n')
|
||||
console.log(`OUTPUT=${JSON.stringify(output)}`)
|
||||
} catch (err) {
|
||||
console.log(err.message)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
async function fetchIssues(labels) {
|
||||
const issues = await octokit.paginate('GET /repos/{owner}/{repo}/issues', {
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
per_page: 100,
|
||||
labels,
|
||||
headers: {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
}
|
||||
})
|
||||
|
||||
return issues
|
||||
}
|
||||
|
||||
async function updateIssue(issue, { labels }) {
|
||||
await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', {
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
issue_number: issue.number,
|
||||
labels,
|
||||
headers: {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function parseIssue(issue) {
|
||||
const buffer = {}
|
||||
const channel = {}
|
||||
const fields = {
|
||||
'Channel Name': 'name',
|
||||
'Alternative Names (optional)': 'alt_name',
|
||||
'Network (optional)': 'network',
|
||||
'Owners (optional)': 'owners',
|
||||
Country: 'country',
|
||||
'Subdivision (optional)': 'subdivision',
|
||||
'City (optional)': 'city',
|
||||
'Broadcast Area': 'broadcast_area',
|
||||
Languages: 'languages',
|
||||
'Categories (optional)': 'categories',
|
||||
NSFW: 'is_nsfw',
|
||||
'Launched (optional)': 'launched',
|
||||
'Closed (optional)': 'closed',
|
||||
'Replaced By (optional)': 'replaced_by',
|
||||
'Website (optional)': 'website',
|
||||
Logo: 'logo'
|
||||
}
|
||||
|
||||
const matches = issue.body.match(/### ([^\r\n]+)[^\w\d]+([^\r\n]+)/g)
|
||||
|
||||
if (!matches) return { issue, channel: null }
|
||||
|
||||
matches.forEach(item => {
|
||||
const [, fieldLabel, value] = item.match(/### ([^\r\n]+)[^\w\d]+([^\r\n]+)/)
|
||||
const field = fields[fieldLabel]
|
||||
|
||||
if (!field) return
|
||||
|
||||
buffer[field] = value === '_No response_' ? undefined : value.trim()
|
||||
})
|
||||
|
||||
for (let field of Object.keys(channelScheme)) {
|
||||
channel[field] = buffer[field]
|
||||
}
|
||||
|
||||
channel.id = generateChannelId(channel.name, channel.country)
|
||||
|
||||
return { issue, channel }
|
||||
}
|
||||
|
||||
function generateChannelId(name, country) {
|
||||
if (name && country) {
|
||||
const slug = name
|
||||
.replace(/\+/gi, 'Plus')
|
||||
.replace(/^@/gi, 'At')
|
||||
.replace(/[^a-z\d]+/gi, '')
|
||||
country = country.toLowerCase()
|
||||
|
||||
return `${slug}.${country}`
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
100
yarn.lock
100
yarn.lock
|
@ -49,6 +49,84 @@
|
|||
dependencies:
|
||||
"moment" "2.x.x"
|
||||
|
||||
"@octokit/auth-token@^3.0.0":
|
||||
"integrity" "sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.3.tgz"
|
||||
"version" "3.0.3"
|
||||
dependencies:
|
||||
"@octokit/types" "^9.0.0"
|
||||
|
||||
"@octokit/core@^4.2.0", "@octokit/core@>=4":
|
||||
"integrity" "sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/core/-/core-4.2.0.tgz"
|
||||
"version" "4.2.0"
|
||||
dependencies:
|
||||
"@octokit/auth-token" "^3.0.0"
|
||||
"@octokit/graphql" "^5.0.0"
|
||||
"@octokit/request" "^6.0.0"
|
||||
"@octokit/request-error" "^3.0.0"
|
||||
"@octokit/types" "^9.0.0"
|
||||
"before-after-hook" "^2.2.0"
|
||||
"universal-user-agent" "^6.0.0"
|
||||
|
||||
"@octokit/endpoint@^7.0.0":
|
||||
"integrity" "sha512-LG4o4HMY1Xoaec87IqQ41TQ+glvIeTKqfjkCEmt5AIwDZJwQeVZFIEYXrYY6yLwK+pAScb9Gj4q+Nz2qSw1roA=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-7.0.5.tgz"
|
||||
"version" "7.0.5"
|
||||
dependencies:
|
||||
"@octokit/types" "^9.0.0"
|
||||
"is-plain-object" "^5.0.0"
|
||||
"universal-user-agent" "^6.0.0"
|
||||
|
||||
"@octokit/graphql@^5.0.0":
|
||||
"integrity" "sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/graphql/-/graphql-5.0.5.tgz"
|
||||
"version" "5.0.5"
|
||||
dependencies:
|
||||
"@octokit/request" "^6.0.0"
|
||||
"@octokit/types" "^9.0.0"
|
||||
"universal-user-agent" "^6.0.0"
|
||||
|
||||
"@octokit/openapi-types@^16.0.0":
|
||||
"integrity" "sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-16.0.0.tgz"
|
||||
"version" "16.0.0"
|
||||
|
||||
"@octokit/plugin-paginate-rest@^6.0.0":
|
||||
"integrity" "sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.0.0.tgz"
|
||||
"version" "6.0.0"
|
||||
dependencies:
|
||||
"@octokit/types" "^9.0.0"
|
||||
|
||||
"@octokit/request-error@^3.0.0":
|
||||
"integrity" "sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/request-error/-/request-error-3.0.3.tgz"
|
||||
"version" "3.0.3"
|
||||
dependencies:
|
||||
"@octokit/types" "^9.0.0"
|
||||
"deprecation" "^2.0.0"
|
||||
"once" "^1.4.0"
|
||||
|
||||
"@octokit/request@^6.0.0":
|
||||
"integrity" "sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/request/-/request-6.2.3.tgz"
|
||||
"version" "6.2.3"
|
||||
dependencies:
|
||||
"@octokit/endpoint" "^7.0.0"
|
||||
"@octokit/request-error" "^3.0.0"
|
||||
"@octokit/types" "^9.0.0"
|
||||
"is-plain-object" "^5.0.0"
|
||||
"node-fetch" "^2.6.7"
|
||||
"universal-user-agent" "^6.0.0"
|
||||
|
||||
"@octokit/types@^9.0.0":
|
||||
"integrity" "sha512-LUewfj94xCMH2rbD5YJ+6AQ4AVjFYTgpp6rboWM5T7N3IsIF65SBEOVcYMGAEzO/kKNiNaW4LoWtoThOhH06gw=="
|
||||
"resolved" "https://registry.npmjs.org/@octokit/types/-/types-9.0.0.tgz"
|
||||
"version" "9.0.0"
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^16.0.0"
|
||||
|
||||
"@sideway/address@^4.1.3":
|
||||
"integrity" "sha512-8ncEUtmnTsMmL7z1YPB47kPUq7LpKWJNFPsRzHiIajGC5uXlWGn+AmkYPcHNl8S4tcEGx+cnORnNYaw2wvL+LQ=="
|
||||
"resolved" "https://registry.npmjs.org/@sideway/address/-/address-4.1.3.tgz"
|
||||
|
@ -147,6 +225,11 @@
|
|||
"resolved" "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz"
|
||||
"version" "1.5.1"
|
||||
|
||||
"before-after-hook@^2.2.0":
|
||||
"integrity" "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
||||
"resolved" "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz"
|
||||
"version" "2.2.3"
|
||||
|
||||
"bl@^4.0.3":
|
||||
"integrity" "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w=="
|
||||
"resolved" "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz"
|
||||
|
@ -473,6 +556,11 @@
|
|||
"resolved" "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz"
|
||||
"version" "1.0.0"
|
||||
|
||||
"deprecation@^2.0.0":
|
||||
"integrity" "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
"resolved" "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz"
|
||||
"version" "2.3.1"
|
||||
|
||||
"detect-libc@^2.0.0", "detect-libc@^2.0.1":
|
||||
"integrity" "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w=="
|
||||
"resolved" "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz"
|
||||
|
@ -871,6 +959,11 @@
|
|||
"resolved" "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz"
|
||||
"version" "1.1.0"
|
||||
|
||||
"is-plain-object@^5.0.0":
|
||||
"integrity" "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
|
||||
"resolved" "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz"
|
||||
"version" "5.0.0"
|
||||
|
||||
"is-utf8@^0.2.0":
|
||||
"integrity" "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI="
|
||||
"resolved" "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz"
|
||||
|
@ -1355,7 +1448,7 @@
|
|||
"resolved" "https://registry.npmjs.org/node-cleanup/-/node-cleanup-2.1.2.tgz"
|
||||
"version" "2.1.2"
|
||||
|
||||
"node-fetch@^2.6.1", "node-fetch@2.6.7":
|
||||
"node-fetch@^2.6.1", "node-fetch@^2.6.7", "node-fetch@2.6.7":
|
||||
"integrity" "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ=="
|
||||
"resolved" "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz"
|
||||
"version" "2.6.7"
|
||||
|
@ -1978,6 +2071,11 @@
|
|||
"resolved" "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz"
|
||||
"version" "4.2.0"
|
||||
|
||||
"universal-user-agent@^6.0.0":
|
||||
"integrity" "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||
"resolved" "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz"
|
||||
"version" "6.0.0"
|
||||
|
||||
"util-deprecate@^1.0.1", "util-deprecate@~1.0.1":
|
||||
"integrity" "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
"resolved" "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
|
||||
|
|
Loading…
Reference in a new issue