Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eagerterrier committed Feb 1, 2025
0 parents commit f67c5a4
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/run-api-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run index and save results

on:
workflow_dispatch:
schedule:
- cron: '*/30 * * * *'
push:
branches:
- main

permissions:
contents: write

jobs:
run-fetchdata:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run index script
run: node index.js

- name: Commit readme files
id: commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if ! git diff --exit-code; then
git add .
git commit -m "Update feeds"
git push
fi
shell: bash
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
/node_modules
72 changes: 72 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const Parser = require('rss-parser');
const fs = require('fs');

const feeds = {
'afaanoromoo': { title: 'afaanoromoo', url: 'https://feeds.bbci.co.uk/afaanoromoo/rss.xml' },
'amharic': { title: 'amharic', url: 'https://feeds.bbci.co.uk/amharic/rss.xml' },
'afrique': { title: 'afrique', url: 'https://feeds.bbci.co.uk/afrique/rss.xml' },
'hausa': { title: 'hausa', url: 'https://feeds.bbci.co.uk/hausa/rss.xml' },
'igbo': { title: 'igbo', url: 'https://feeds.bbci.co.uk/igbo/rss.xml' },
'gahuza': { title: 'gahuza', url: 'https://feeds.bbci.co.uk/gahuza/rss.xml' },
'pidgin': { title: 'pidgin', url: 'https://feeds.bbci.co.uk/pidgin/rss.xml' },
'somali': { title: 'somali', url: 'https://feeds.bbci.co.uk/somali/rss.xml' },
'swahili': { title: 'swahili', url: 'https://feeds.bbci.co.uk/swahili/rss.xml' },
'tigrinya': { title: 'tigrinya', url: 'https://feeds.bbci.co.uk/tigrinya/rss.xml' },
'yoruba': { title: 'yoruba', url: 'https://feeds.bbci.co.uk/yoruba/rss.xml' },
'kyrgyz': { title: 'kyrgyz', url: 'https://feeds.bbci.co.uk/kyrgyz/rss.xml' },
'uzbek': { title: 'uzbek', url: 'https://feeds.bbci.co.uk/uzbek/rss.xml' },
'burmese': { title: 'burmese', url: 'https://feeds.bbci.co.uk/burmese/rss.xml' },
'zhongwen-simp': { title: 'zhongwen', url: 'https://feeds.bbci.co.uk/zhongwen/simp/rss.xml' },
'zhongwen-trad': { title: 'zhongwen', url: 'https://feeds.bbci.co.uk/zhongwen/trad/rss.xml' },
'indonesia': { title: 'indonesia', url: 'https://feeds.bbci.co.uk/indonesia/rss.xml' },
'japanese': { title: 'japanese', url: 'https://feeds.bbci.co.uk/japanese/rss.xml' },
'korean': { title: 'korean', url: 'https://feeds.bbci.co.uk/korean/rss.xml' },
'thai': { title: 'thai', url: 'https://feeds.bbci.co.uk/thai/rss.xml' },
'vietnamese': { title: 'vietnamese', url: 'https://feeds.bbci.co.uk/vietnamese/rss.xml' },
'bengali': { title: 'bengali', url: 'https://feeds.bbci.co.uk/bengali/rss.xml' },
'gujarati': { title: 'gujarati', url: 'https://feeds.bbci.co.uk/gujarati/rss.xml' },
'hindi': { title: 'hindi', url: 'https://feeds.bbci.co.uk/hindi/rss.xml' },
'marathi': { title: 'marathi', url: 'https://feeds.bbci.co.uk/marathi/rss.xml' },
'nepali': { title: 'nepali', url: 'https://feeds.bbci.co.uk/nepali/rss.xml' },
'pashto': { title: 'pashto', url: 'https://feeds.bbci.co.uk/pashto/rss.xml' },
'punjabi': { title: 'punjabi', url: 'https://feeds.bbci.co.uk/punjabi/rss.xml' },
'sinhala': { title: 'sinhala', url: 'https://feeds.bbci.co.uk/sinhala/rss.xml' },
'tamil': { title: 'tamil', url: 'https://feeds.bbci.co.uk/tamil/rss.xml' },
'telugu': { title: 'telugu', url: 'https://feeds.bbci.co.uk/telugu/rss.xml' },
'urdu': { title: 'urdu', url: 'https://feeds.bbci.co.uk/urdu/rss.xml' },
'azeri': { title: 'azeri', url: 'https://feeds.bbci.co.uk/azeri/rss.xml' },
'russian': { title: 'russian', url: 'https://feeds.bbci.co.uk/russian/rss.xml' },
'serbian-lat': { title: 'serbian', url: 'https://feeds.bbci.co.uk/serbian/lat/rss.xml' },
'serbian-cyr': { title: 'serbian', url: 'https://feeds.bbci.co.uk/serbian/cyr/rss.xml' },
'turkce': { title: 'turkce', url: 'https://feeds.bbci.co.uk/turkce/rss.xml' },
'ukrainian': { title: 'ukrainian', url: 'https://feeds.bbci.co.uk/ukrainian/rss.xml' },
'portuguese': { title: 'portuguese', url: 'https://feeds.bbci.co.uk/portuguese/rss.xml' },
'mundo': { title: 'mundo', url: 'https://feeds.bbci.co.uk/mundo/rss.xml' },
'arabic': { title: 'arabic', url: 'https://feeds.bbci.co.uk/arabic/rss.xml' },
'persian': { title: 'persian', url: 'https://feeds.bbci.co.uk/persian/rss.xml' },
};


let parser = new Parser({
customFields: {
item: [
['media:thumbnail', 'mediathumbnail'],
]
}
});

Object.keys(feeds).forEach((service, i) => {
setTimeout( () => {
(async () => {
const url = feeds[service].url;
console.log(`fetching ${url}`);
let feed = await parser.parseURL(url);
let md_contents = `# ${feed.title}\r\r`;

feed.items.forEach(item => {
md_contents += `## [${item.title}](${item.link})\r![${item.title}](${item.mediathumbnail.$.url})\r\r${item.contentSnippet}\r\r\r`;
});
fs.writeFileSync(`./${service}.md`, md_contents);

})()}, 500 * i)
});
54 changes: 54 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"rss-parser": "^3.13.0"
}
}
49 changes: 49 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# BBC World Service RSS Feeds output

A list of the most recent stories from across the world in your language

## Feeds

- [afaanoromoo](./afaanoromoo.md)
- [afrique](./afrique.md)
- [amharic](./amharic.md)
- [arabic](./arabic.md)
- [azeri](./azeri.md)
- [bengali](./bengali.md)
- [burmese](./burmese.md)
- [gahuza](./gahuza.md)
- [gujarati](./gujarati.md)
- [hausa](./hausa.md)
- [hindi](./hindi.md)
- [igbo](./igbo.md)
- [indonesia](./indonesia.md)
- [japanese](./japanese.md)
- [korean](./korean.md)
- [kyrgyz](./kyrgyz.md)
- [marathi](./marathi.md)
- [mundo](./mundo.md)
- [nepali](./nepali.md)
- [pashto](./pashto.md)
- [persian](./persian.md)
- [pidgin](./pidgin.md)
- [portuguese](./portuguese.md)
- [punjabi](./punjabi.md)
- [russian](./russian.md)
- [serbian cyr](./serbian-cyr.md)
- [serbian lat](./serbian-lat.md)
- [sinhala](./sinhala.md)
- [somali](./somali.md)
- [swahili](./swahili.md)
- [tamil](./tamil.md)
- [telugu](./telugu.md)
- [thai](./thai.md)
- [tigrinya](./tigrinya.md)
- [turkce](./turkce.md)
- [ukrainian](./ukrainian.md)
- [urdu](./urdu.md)
- [uzbek](./uzbek.md)
- [vietnamese](./vietnamese.md)
- [yoruba](./yoruba.md)
- [zhongwen simp](./zhongwen-simp.md)
- [zhongwen trad](./zhongwen-trad.md)

0 comments on commit f67c5a4

Please sign in to comment.