Giter Site home page Giter Site logo

npo-poms / scripts Goto Github PK

View Code? Open in Web Editor NEW
0.0 11.0 0.0 26.48 MB

Scripts to talk to POMS Backend Rest API

Home Page: https://api.poms.omroep.nl

License: GNU General Public License v2.0

Shell 8.24% XSLT 2.57% Python 79.96% Makefile 3.50% Gnuplot 0.37% Java 4.14% Dockerfile 0.27% Mustache 0.61% CSS 0.34%
npo

scripts's Introduction

poms-scripts

Table of Contents

Scripts to talk to POMS Rest API.

XML

Some plain XML examples can be found in examples

Python

For python we maintain a 'poms.py' which is imported in the other python scripts. It provides a simple shelve-database with settings you use, and maps the rest-calls which are used in the scripts.

michiel@baleno:~/github/npo-poms/scripts/python$ ./post.py -r -t dev  ../examples/program.xml
Username for https://api-dev.poms.omroep.nl/media/: vpro-mediatools
Password:
Username/password stored in file creds.db. Use -r to set it.
posting  to https://api-dev.poms.omroep.nl/media/media?[email protected]
crid://bds.tv/9876,crid://tmp.fragment.mmbase.vpro.nl/1234
michiel@baleno:~/github/npo-poms/scripts/python$

This is quite straight forward and was later improved to be an actual (python library)[https://github.com/npo-poms/pyapi]. Some scripts in the python directory of this project make use of that library.

Groovy/Java

Since POMS is written in Java, it is actually feasible to use its domain objects in your scripts. Rest clients are available, which use these domain objects directly.

MediaRestClient client = new MediaRestClient();
client.setUrl(mediaRsUrl);
client.setUserName(userName);
client.setPassword(password);
client.setErrors(getMail());
..
GroupUpdate group = client.getGroup(id);
..

group.setPublishStart(onlineDate);

client.set(group);

In the directory java of this project we appear code that (temporary) used these clients.

Bash/XSLT

Simply calling 'curl' in shell script is of course possible too. These scripts include a 'creds.sh'. A template 'copy.to.creds.sh' is available. Do that and provide your own credentials in it. Most scripts can be prefixed with the environment:

michiel@belono:~/github/npo-poms/scripts/bash$ ENV=prod ./unpublish.sh WO_VPRO_717563
posting:
<?xml version="1.0"?>
<program xmlns="urn:vpro:media:update:2009" type="CLIP" avType="VIDEO" embeddable="true" mid="WO_VPRO_717563" publishStop="2015-02-07T11:28:05Z" urn="urn:vpro:media:program:48270798">
  <broadcaster xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009">VPRO</broadcaster>
  <title xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009" type="MAIN">test</title>
  <locations xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
  <scheduleEvents xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
  <images xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
  <segments xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
</program>
result:
WO_VPRO_717563

Sometimes operations involve modifying XML, which is done using xsltproc/XSLT in these scripts.

scripts's People

Contributors

giorgiovinci avatar lkmbrnk avatar mihxil avatar raanelom avatar ricojansen avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.