sondakika 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +102 -0
- package/package.json +1 -1
package/cli.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const blessed = require('blessed');
|
|
4
|
+
const RssParser = require('rss-parser');
|
|
5
|
+
const parser = new RssParser();
|
|
6
|
+
|
|
7
|
+
const sources = {
|
|
8
|
+
cumhuriyet: { name: 'Cumhuriyet', url: 'https://www.cumhuriyet.com.tr/rss/son_dakika.xml', type: 'breaking' },
|
|
9
|
+
trt: { name: 'TRT Haber', url: 'https://www.trthaber.com/son-dakika.rss', type: 'breaking' },
|
|
10
|
+
mynet: { name: 'Mynet', url: 'https://www.mynet.com/rss/son-dakika/', type: 'breaking' },
|
|
11
|
+
sabah: { name: 'Sabah', url: 'https://www.sabah.com.tr/rss/son-dakika.xml', type: 'news' },
|
|
12
|
+
star: { name: 'Star', url: 'https://www.star.com.tr/rss/son-dakika.xml', type: 'news' },
|
|
13
|
+
vatan: { name: 'Gazete Vatan', url: 'https://www.gazetevatan.com/rss/son-dakika.xml', type: 'news' },
|
|
14
|
+
haberturk: { name: 'Habertürk', url: 'https://www.haberturk.com/rss/son-dakika.xml', type: 'news' },
|
|
15
|
+
cnnturk: { name: 'CNN Türk', url: 'https://www.cnnturk.com/feed/rss', type: 'news' },
|
|
16
|
+
yenisafak: { name: 'Yeni Şafak', url: 'https://www.yenisafak.com/rss/son-dakika.xml', type: 'news' },
|
|
17
|
+
aa: { name: 'Anadolu Ajansı', url: 'https://www.aa.com.tr/tr/rss/default?cat=guncel', type: 'news' }
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const sourceArg = args[0];
|
|
22
|
+
const countArg = parseInt(args[1]) || 10;
|
|
23
|
+
|
|
24
|
+
if (!sourceArg || !sources[sourceArg]) {
|
|
25
|
+
console.log(`
|
|
26
|
+
📰 Sondakika - Türkçe Haber Okuyucu
|
|
27
|
+
|
|
28
|
+
Kullanım:
|
|
29
|
+
sondakika <kaynak> [adet]
|
|
30
|
+
|
|
31
|
+
Mevcut Kaynaklar:
|
|
32
|
+
Son Dakika:
|
|
33
|
+
cumhuriyet - Cumhuriyet
|
|
34
|
+
trt - TRT Haber
|
|
35
|
+
mynet - Mynet
|
|
36
|
+
|
|
37
|
+
Haberler:
|
|
38
|
+
sabah - Sabah
|
|
39
|
+
star - Star
|
|
40
|
+
vatan - Gazete Vatan
|
|
41
|
+
haberturk - Habertürk
|
|
42
|
+
cnnturk - CNN Türk
|
|
43
|
+
yenisafak - Yeni Şafak
|
|
44
|
+
aa - Anadolu Ajansı
|
|
45
|
+
|
|
46
|
+
Örnekler:
|
|
47
|
+
sondakika trt
|
|
48
|
+
sondakika cumhuriyet 20
|
|
49
|
+
sondakika haberturk 5
|
|
50
|
+
`);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const source = sources[sourceArg];
|
|
55
|
+
|
|
56
|
+
async function fetchNews() {
|
|
57
|
+
try {
|
|
58
|
+
const feed = await parser.parseURL(source.url);
|
|
59
|
+
const items = feed.items.slice(0, countArg);
|
|
60
|
+
|
|
61
|
+
const screen = blessed.screen({ smartCSR: true });
|
|
62
|
+
const box = blessed.box({
|
|
63
|
+
top: 0,
|
|
64
|
+
left: 0,
|
|
65
|
+
width: '100%',
|
|
66
|
+
height: '100%',
|
|
67
|
+
content: `{center}📰 ${source.name} - Son Dakika{/center}`,
|
|
68
|
+
tags: true,
|
|
69
|
+
border: { type: 'line' },
|
|
70
|
+
style: { border: { fg: 'cyan' } }
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
screen.append(box);
|
|
74
|
+
screen.render();
|
|
75
|
+
screen.destroy();
|
|
76
|
+
screen.program.destroy();
|
|
77
|
+
|
|
78
|
+
console.log(`\n📰 ══════════════════════════════════════════════════`);
|
|
79
|
+
console.log(` ${source.name} - Son ${countArg} Haber`);
|
|
80
|
+
console.log(` ══════════════════════════════════════════════════\n`);
|
|
81
|
+
|
|
82
|
+
items.forEach((item, index) => {
|
|
83
|
+
const date = item.pubDate ? new Date(item.pubDate).toLocaleString('tr-TR') : '';
|
|
84
|
+
console.log(` ┌─ ${index + 1}. ${item.title}`);
|
|
85
|
+
console.log(` │`);
|
|
86
|
+
console.log(` │ 📅 ${date}`);
|
|
87
|
+
console.log(` │`);
|
|
88
|
+
if (item.contentSnippet) {
|
|
89
|
+
const snippet = item.contentSnippet.substring(0, 100).replace(/\n/g, ' ');
|
|
90
|
+
console.log(` │ ${snippet}...`);
|
|
91
|
+
}
|
|
92
|
+
console.log(` └─────────────────────────────────────────────────────────────────────`);
|
|
93
|
+
console.log(` 🔗 ${item.link}\n`);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('Haberler alınırken hata oluştu:', error.message);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fetchNews();
|