Command line tool to import events into federated service mobilizon.
 
 
Go to file
Lio Novelli 194cda071d Minor change. 2021-10-01 11:12:53 +02:00
mobili_cli Merge branch 'master' of https://git.kompot.si/lio/mobili_cli 2021-10-01 01:56:02 +02:00
mobili_cli.egg-info Merge branch 'master' of https://git.kompot.si/lio/mobili_cli 2021-10-01 01:56:02 +02:00
primeri Class for event, better sh script for testing, added kulturnik 2021-09-30 21:54:10 +02:00
.gitignore Read image from metadata, gitignore updates, cleanup cache py files 2021-09-30 22:14:33 +02:00
LICENSE Dodana AGPL licenca 2021-09-23 23:22:24 +02:00
README.org Minor change. 2021-10-01 11:12:53 +02:00
requirements.txt Merge branch 'master' of https://git.kompot.si/lio/mobili_cli 2021-10-01 01:56:02 +02:00
setup.py Merge branch 'master' of https://git.kompot.si/lio/mobili_cli 2021-10-01 01:56:02 +02:00

README.org

Mobilizon importer

File and rss importer into mobilizon graphql api.

Installation and usage

  git clone https://git.kompot.si/lio/mobili_cli
  cd mobili_cli

  pip3 install -e .

  export PATH=~/.local/bin/:$PATH

  mobili_cli cli --help

Functionality

Login

Get events

Create event

  • options:

    • update existing
    • skip existing
From file
User input
Rss feed
Verificiraj ali dogodek ze obstaja
  • za rss feed lahko uporabimo link

Structure

Python requests

  import requests
  import json
  endpoint='https://dogodki.kompot.si/api'
  body='''
  query {
    events {
      elements {
        id,
        url,
        title,
        description,
        beginsOn,
        endsOn,
        status,
        picture {
          url
        },
        physicalAddress {
          id,
          description,
          locality
        }
      }
      total
    }
  }
  '''
  r = requests.post(endpoint, json={'query':body}, '')
  r = requests.post(endpoint, json={"query":body}, headers='')
  r.status_code
  print(json.dumps(r.json(), indent=2))
  body
  body2='''
  query {
    events {
      elements {
        id,
        url,
        title,
        description,
        beginsOn,
        endsOn,
        status,
        picture {
          url
        },
        physicalAddress {
          id,
          description,
          locality
        }
      }
    }
  }
  '''
  body2='''
  query {
    groups {
      elements {
        id,
        name,
        domain,
        page
      }
    }
  }
  '''
  r2 = requests.post(endpoint, json={"query":body2}, headers='')
  print(json.dumps(r2.json(), indent=2))
  body2="query{grups{elements{id,name}}}"
  r2 = requests.post(endpoint, json={"query":body2}, headers='')
  r2.status_code
  print(json.dumps(r2.json(), indent=2))
  b2
  body2
  body2="query{\ngrups{\nelements{\nid,\nname\n}\n}\n}"
  r2 = requests.post(endpoint, json={"query":body2}, headers='')
  r2.status_code
  r2 = requests.post(endpoint, json={"query":body2}, headers='')
  print(json.dumps(r2.json(), indent=2))
  bl='''
  mutation Login($email: String!, $password: String!) {
      login(email: $email, password: $password) {
        accessToken
        refreshToken
        user {
          id
          email
          role
        }
      }
    }
  '''
  varsl= {'email': 'lio@kompot.si', 'password': '<geslo>'}
  r3=requests.post(endpoint, json={"query": bl, 'variables': varsl}, headers='')
  r3.status_code
  print(json.dumps(r3json(), indent=2))
  print(json.dumps(r3.json(), indent=2))
  r3.json()
  r3.json().data
  r3.json().get('data')
  r3.json().get('data').get.('login')
  r3.json().get('data').get('login')
  r3.json().get('data').get('login').get('login')
  r3.json().get('data').get('login').get('accessToken')
  r3.json().get('data.login')
  j=r3.json()
  data=json.loads(j)
  j
  data=json.loads(j)
  print j['data']['login']['accessToken']
  j
  j['data']
  j['data']['login']
  j['data']['login']['accessToken']
  at=j['data']['login']['accessToken']
  head={"Authorization": f"Bearer {at}"}
  r2 = requests.post(endpoint, json={"query":body2}, headers='')
  print(json.dumps(r2.json(), indent=2))
  bg="query{groups{elements{id,name}\ntotal}}"
  r2 = requests.post(endpoint, json={"query":body2}, headers='')
  print(json.dumps(r2.json(), indent=2))
  bg="query {\ngroups {\nelements {\nid,\nname}\ntotal\n}\n}"
  bg
  r2 = requests.post(endpoint, json={"query":bg}, headers=head)
  r2.status_code
  print(json.dumps(r2.json(), indent=2))

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.