diff --git a/packages/content-handler/src/index.ts b/packages/content-handler/src/index.ts index 2993fa1d9..b57b36ddf 100644 --- a/packages/content-handler/src/index.ts +++ b/packages/content-handler/src/index.ts @@ -32,6 +32,7 @@ import { Browser } from 'puppeteer-core' import { StackOverflowHandler } from './websites/stack-overflow-handler' import { GenericHandler } from './newsletters/generic-handler' import { EveryIoHandler } from './newsletters/every-io-handler' +import { EnergyWorldHandler } from './newsletters/energy-world' const validateUrlString = (url: string) => { const u = new URL(url) @@ -84,6 +85,7 @@ const newsletterHandlers: ContentHandler[] = [ new HeyWorldHandler(), new GenericHandler(), new EveryIoHandler(), + new EnergyWorldHandler(), ] export const preHandleContent = async ( diff --git a/packages/content-handler/src/newsletters/energy-world.ts b/packages/content-handler/src/newsletters/energy-world.ts new file mode 100644 index 000000000..d66f487a6 --- /dev/null +++ b/packages/content-handler/src/newsletters/energy-world.ts @@ -0,0 +1,19 @@ +import { ContentHandler } from '../content-handler' + +export class EnergyWorldHandler extends ContentHandler { + constructor() { + super() + this.name = 'Energy World' + } + + async isNewsletter(input: { + from: string + html: string + headers: Record + dom: Document + }): Promise { + return Promise.resolve( + input.from === 'ETEnergyworld Latest News' + ) + } +} diff --git a/packages/content-handler/test/data/energy-world-newsletter.html b/packages/content-handler/test/data/energy-world-newsletter.html new file mode 100644 index 000000000..e29ac22e0 --- /dev/null +++ b/packages/content-handler/test/data/energy-world-newsletter.html @@ -0,0 +1,384 @@ + + +ETEnergyworld Latest news + +
Adani saga: RBI seeks details, Citigroup stops margin loans| Greenko places largest electrolysers order| PM-KUSUM extended
+
+ Unsubscribe +   |   + Report this Email +
+ + + + +
+
+
+ + +
ETEnergyworld Newsletter | Friday, February 3, 2023 +
+ +
+
Daily Newsletter +
+ +
+
+
Supported by
+ + + + +
FIPIicppaappippai
+ +
+ + + + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ Top Stories +
+ + RBI seeks details of banks' exposure to Adani Group + +
+ + Adani empire loses more than $100 bn after fraud claims + +
+ + Citigroup stops margin loans against India Adani's securities - source + +
+ + Greenko places India's largest 140 MW electrolysers order on John Cockerill + +
+ + Govt extends PM-KUSUM scheme till March 2026 as COVID affects implementation + +
+ + Indian state oil companies to spend $13 billion in fiscal 2024 + +
+ + Joshimath: Cracks begin to show in India's Himalayan building spree + +
+ + Budget 2023 reinforced India's green transformation objective but more was needed + +
+ + VIDEO: Budget 2023 - Panel discussion on key provisions for the energy sector + +
+
+ + + + + + + + + + + + + + +
+ Oil & Gas +
+ + Fuel subsidies are back: Oil companies to get Rs 30,000 cr for holding petrol, diesel prices + +
+ + 'Russia has become largest oil supplier to India': Russian Ambassador to Delhi + +
+ + Ukraine lawmaker calls on US to target China, India energy purchases + +
+ + Rosneft shows how energy-saving tech can minimise environmental impact + +
+ + Crude oil prices retain bullish pulse in 2023 as fundamentals in top gear + +
+ + OPEC+ committee recommends to stay course on oil ouput cuts + +
+ + Shell annual profit hits record $42 billion as Ukraine invasion sent prices soaring + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ Renewable +
+ + Why is Gautam Adani's Indian empire in turmoil? + +
+ + Sitharaman urges industry to set standards in renewable energy + +
+ + No impact of Adani Group firms' stock rout, India has 15 to 16 large firms in renewables, says R K Singh + +
+ + Adani's adversity raises the stakes for India and investors + +
+ + Budget 2023: The seven Saptarishis for green growth + +
+ + Green bonds, SLBs, MDBs in focus at G20 meet on sustainable finance + Business Standard +
+ + India on course to meet green energy targets: Experts + +
+ + Rs 35K cr for energy transition: Energy sector awaits disbursement details + Business Standard +
+ + Asia faces shortage of ships to install offshore mega wind farms + +
+ + Solar tech firm Nextracker aims to raise up to $534.9 mln in U.S. IPO + +
+ + Four West African nations get $311 million from World Bank for renewables + +
+ + Trina Solar publishes white paper on 210mm n-type i-TOPCon advanced technology, and upgraded Vertex N 605W/695W leads among utilities by high value + +
+
+ + +
+ + + + +
+ + + + + + + + + + + + +
+ Power +
+ + Bangladesh wants revision of power purchase deal with Adani + +
+ + Storage plants to help meet power demand in long run: RK Singh + +
+ + NTPC's power project far away from Joshimath, says Power Minister in Parliament + +
+ + Govt nearly doubles allocation under FAME-2 subsidy scheme + +
+ + DISCOMs Owed 329 Billion to Power Generators as of January 2023 + Mercom India +
+ + Mahindra Electric Mobility merges with parent Mahindra & Mahindra + +
+
+ + + + +
+ Coal +
+ + No power supply disruption due to high demand; will not hesitate to import coal: RK Singh + +
+ + Railways eyes doubling of earnings from coal loading in FY24 + The Hindu Business Line +
+
+
+ + + + + +
+ + + + +
+ + + +
+ + +
+
+ +
+ + Follow Us on + +
+ + + + +
+ +
+
+ Copyright © 2023 ETEnergyworld, All rights reserved. +
+
+ You are receiving this email because you signed up at etenergyworld.com +
+
+
Our mailing address is: + ETEnergyworld.com (Times Center), FC6, Sector 16 A, Film City, Noida - 201301 Uttar Pradesh, + India +
+
+
+ Add newsletter@etenergyworld.com to your address book   |   + Our archives are at + ETEnergyworld + +
+ +
+
+ Unsubscribe +   |   + Report this Email +
diff --git a/packages/content-handler/test/newsletter.test.ts b/packages/content-handler/test/newsletter.test.ts index 0630783a2..86925e2a9 100644 --- a/packages/content-handler/test/newsletter.test.ts +++ b/packages/content-handler/test/newsletter.test.ts @@ -9,7 +9,7 @@ import { BloombergNewsletterHandler } from '../src/newsletters/bloomberg-newslet import { GolangHandler } from '../src/newsletters/golang-handler' import { MorningBrewHandler } from '../src/newsletters/morning-brew-handler' import nock from 'nock' -import { ContentHandler, generateUniqueUrl } from '../src/content-handler' +import { generateUniqueUrl } from '../src/content-handler' import fs from 'fs' import { BeehiivHandler } from '../src/newsletters/beehiiv-handler' import { ConvertkitHandler } from '../src/newsletters/convertkit-handler' @@ -20,6 +20,7 @@ import { parseHTML } from 'linkedom' import { HeyWorldHandler } from '../src/newsletters/hey-world-handler' import { GenericHandler } from '../src/newsletters/generic-handler' import { EveryIoHandler } from '../src/newsletters/every-io-handler' +import { EnergyWorldHandler } from '../src/newsletters/energy-world' chai.use(chaiAsPromised) chai.use(chaiString) @@ -261,7 +262,7 @@ describe('Newsletter email test', () => { expect(handler).to.be.instanceOf(CooperPressHandler) }) - it('returns ContentHandler for hey world newsletter', async () => { + it('returns HeyWorldHandler for hey world newsletter', async () => { const html = load('./test/data/hey-world-newsletter.html') const handler = await getNewsletterHandler({ html, @@ -271,7 +272,7 @@ describe('Newsletter email test', () => { '', }, }) - expect(handler).to.be.instanceOf(ContentHandler) + expect(handler).to.be.instanceOf(HeyWorldHandler) }) it('returns ConvertkitHandler for Tomasz Tunguz newsletter', async () => { @@ -317,6 +318,16 @@ describe('Newsletter email test', () => { }) expect(handler).to.be.instanceOf(EveryIoHandler) }) + + it('returns EnergyWorldHandler for energy world newsletter', async () => { + const html = load('./test/data/energy-world-newsletter.html') + const handler = await getNewsletterHandler({ + html, + from: 'ETEnergyworld Latest News', + headers: {}, + }) + expect(handler).to.be.instanceOf(EnergyWorldHandler) + }) }) describe('findNewsletterUrl', async () => {