Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bang parser, assume timezone is London not UTC #931

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions server/aap/io/feed_parsers/bang_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from superdesk.utc import utc
import pytz
from superdesk.io.feed_parsers.newsml_1_2 import NewsMLOneFeedParser
from superdesk.io.registry import register_feed_parser
from superdesk.errors import ParserError
Expand All @@ -24,7 +24,11 @@ class BangShowbizParser(NewsMLOneFeedParser):
subject_map = {MUSIC_ID: "01011000", MOVIES_ID: "01005001", SHOWBIZ_ID: "01021000"}

def datetime(self, string):
return datetime.strptime(string, "%Y-%m-%d %H:%M:%S").replace(tzinfo=utc)
# Assume that timezone of the input datetime is London
local_dt = datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
local_tz = pytz.timezone("Europe/London")
utc_dt = local_tz.localize(local_dt, is_dst=None).astimezone(pytz.utc)
return utc_dt

def parse(self, xml, provider=None):
self.provider = provider
Expand Down Expand Up @@ -89,6 +93,7 @@ def parse_news_identifier(self, item, tree):
def parse_news_management(self, item, tree):
# It's always entertainment
item["anpa_category"] = [{"qcode": "e"}]
item["original_source"] = "BANG"


register_feed_parser(BangShowbizParser.NAME, BangShowbizParser())
Loading