Merge branch 'master' of https://git.kompot.si/lio/mobili_cli
commit
f8a916db03
|
@ -1,2 +1,4 @@
|
||||||
scratch
|
scratch
|
||||||
|
**/__pycache__/
|
||||||
|
.#*
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
*** developing in guix
|
*** developing in guix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
** Python requests
|
** Python requests
|
||||||
|
|
||||||
#+BEGIN_EXAMPLE python
|
#+BEGIN_EXAMPLE python
|
||||||
|
@ -178,3 +177,9 @@
|
||||||
|
|
||||||
#+END_EXAMPLE
|
#+END_EXAMPLE
|
||||||
|
|
||||||
|
|
||||||
|
** RSS import
|
||||||
|
This tool can be used to import events from a RSS feed.
|
||||||
|
Once run, it checks if there are new events to be added and updates existing ones if need be.
|
||||||
|
*** Identification
|
||||||
|
Each event is uniquely identified by its' url ("link" field), which is mapped into the "link" field on mobilizon.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
setup.py
|
setup.py
|
||||||
mobili_cli/__init__.py
|
mobili_cli/__init__.py
|
||||||
mobili_cli/cli.py
|
mobili_cli/cli.py
|
||||||
|
mobili_cli/event.py
|
||||||
mobili_cli.egg-info/PKG-INFO
|
mobili_cli.egg-info/PKG-INFO
|
||||||
mobili_cli.egg-info/SOURCES.txt
|
mobili_cli.egg-info/SOURCES.txt
|
||||||
mobili_cli.egg-info/dependency_links.txt
|
mobili_cli.egg-info/dependency_links.txt
|
||||||
|
@ -10,4 +11,7 @@ mobili_cli.egg-info/top_level.txt
|
||||||
mobili_cli/commands/__init__.py
|
mobili_cli/commands/__init__.py
|
||||||
mobili_cli/commands/cmd_init.py
|
mobili_cli/commands/cmd_init.py
|
||||||
mobili_cli/commands/cmd_status.py
|
mobili_cli/commands/cmd_status.py
|
||||||
mobili_cli/commands/cmd_test.py
|
mobili_cli/commands/cmd_test.py
|
||||||
|
mobili_cli/utils/__init__.py
|
||||||
|
mobili_cli/utils/authenticate.py
|
||||||
|
mobili_cli/utils/load-rss-feed.py
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from pprint import pp
|
||||||
|
from datetime import datetime
|
||||||
|
from metadata_parser import MetadataParser
|
||||||
|
|
||||||
|
class Event:
|
||||||
|
status = None
|
||||||
|
|
||||||
|
def __init__(self, title, time, link):
|
||||||
|
self.title = title
|
||||||
|
self.time = time
|
||||||
|
self.link = link
|
||||||
|
|
||||||
|
def setStatus(self, status):
|
||||||
|
self.status = status
|
||||||
|
|
||||||
|
def setLocation(self, location):
|
||||||
|
self.location = location
|
||||||
|
|
||||||
|
def setImageFromLink(self, link):
|
||||||
|
page = MetadataParser(self.link)
|
||||||
|
self.image = page.get_metadata_link('image')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str({
|
||||||
|
'title': self.title,
|
||||||
|
'time': self.time,
|
||||||
|
'link': self.link,
|
||||||
|
'status': self.status,
|
||||||
|
'image': self.image
|
||||||
|
})
|
||||||
|
|
||||||
|
def parseRSS(entry):
|
||||||
|
for k in ['title', 'ical_dtstart', 'link']:
|
||||||
|
if k not in entry:
|
||||||
|
raise ValueError(f"{k} is a required event parameter")
|
||||||
|
|
||||||
|
title, time, link = (entry.title, datetime.fromisoformat(entry['ical_dtstart']), entry.link)
|
||||||
|
ev = Event(title, time, link)
|
||||||
|
|
||||||
|
if 'ical_status' in entry:
|
||||||
|
ev.setStatus(entry['ical_status'])
|
||||||
|
|
||||||
|
if 'ical_location' in entry:
|
||||||
|
ev.setLocation(entry['ical_location'])
|
||||||
|
|
||||||
|
ev.setImageFromLink(ev.link)
|
||||||
|
|
||||||
|
return ev
|
|
@ -2,15 +2,18 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import feedparser
|
import feedparser
|
||||||
|
from pprint import pp
|
||||||
|
|
||||||
|
from mobili_cli.event import Event, parseRSS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = sys.argv[1]
|
url = sys.argv[1]
|
||||||
|
|
||||||
f = feedparser.parse(url)
|
|
||||||
for dogodek in f['entries']:
|
|
||||||
print(dogodek)
|
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SystemExit('Usage: load-rss-feed.py <url of rss feed>')
|
raise SystemExit('Usage: load-rss-feed.py <url of rss feed>')
|
||||||
|
|
||||||
|
f = feedparser.parse(url)
|
||||||
|
for e in f['entries']:
|
||||||
|
pp(e)
|
||||||
|
event = parseRSS(e)
|
||||||
|
pp(str(event))
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
polnapot=$(realpath $0)
|
||||||
|
pot=$(dirname $polnapot)
|
||||||
|
url="https://dogodki.kulturnik.si/?format=rss"
|
||||||
|
|
||||||
|
$pot/../mobili_cli/utils/load-rss-feed.py $url
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
polnapot=$(realpath $0)
|
||||||
|
pot=$(dirname $polnapot)
|
||||||
url="https://www.neodvisni.art/novice/feed"
|
url="https://www.neodvisni.art/novice/feed"
|
||||||
|
|
||||||
../mobili_cli/utils/load-rss-feed.py $url
|
$pot/../mobili_cli/utils/load-rss-feed.py $url
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
click>=7.0.0
|
click>=7.0.0
|
||||||
sgqlc==v14.1
|
sgqlc==v14.1
|
||||||
feedparser==6.0.8
|
feedparser==6.0.8
|
||||||
|
metadata-parser==0.10.5
|
||||||
|
lxml==4.6.3
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open('requirements.txt') as f:
|
||||||
setup(
|
setup(
|
||||||
name="mobili_cli",
|
name="mobili_cli",
|
||||||
version="0.1",
|
version="0.1",
|
||||||
packages=["mobili_cli", "mobili_cli.commands"],
|
packages=["mobili_cli", "mobili_cli.commands", "mobili_cli.utils"],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=required,
|
install_requires=required,
|
||||||
entry_points="""
|
entry_points="""
|
||||||
|
|
Loading…
Reference in New Issue