GithubHelp home page GithubHelp logo

jedevc / bhamcal Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 2.0 76 KB

A timetable extractor for University of Birmingham! :calendar:

License: GNU General Public License v3.0

Python 99.23% Dockerfile 0.77%

bhamcal's Introduction

Birmingham Uni timetable extractor

The University of Birmingham has a lovely service for accessing timetables that is completely incompatible with any reasonable system. This is a simple command line tool to extract the data from my.bham and generate something compatible with a reasonable system.

This project is loosely inspired by Tom Moses' work on OnlineBhamTimetableConverter. It's a great project, however, I'm generally unhappy about having to give my password off to third-party services, and I just need a simple command line tool.

Quick start

You can get started easily using the prebuilt docker image:

$ docker run -ti -v $(pwd):/data jedevc/bhamcal <username> -f /data/out.ical

An iCalendar file will be created in your current directory that you can then install into whatever mail app you use.

Installation

bhamcal requires at least python 3.7, as it uses some slightly more modern features.

Finally, to actually install bhamcal, clone the repository, and install it using pip:

$ git clone https://github.com/jedevc/bhamcal.git
$ cd bhamcal
$ pip3 install -e .

If you don't want to install it system-wide, you can run it as a module, after installing the dependencies:

$ pip3 install -r requirements.txt
$ python3 -m bhamcal

Usage

To generate a calendar format:

$ bhamcal <username> -o calendar.ics

For other options, see the help:

$ bhamcal --help

Output formats

bhamcal can output calendars in a variety of different formats. However, each has it's own instructions and quirks.

iCalendar

iCalendar is the default, recommended output format. It's the most comprehensive, feature-full format out there for calendars and is understood by almost all calendar software.

To generate an iCalendar:

$ python -m bhamcal <username> -f ical -o calendar.ics

CSV

CSV outputs are the simplest in terms of complexity, and should be accepted in most places, however, they don't contain the full complexity that iCalendar can and should only be used when iCalendar is not available.

To generate a CSV:

$ python -m bhamcal <username> -f csv -o calendar.csv

Google Calendar

Google Calendar outputs are the most complicated to setup.

First we need to setup a Google Cloud project so we can access the Google Calendar API:

  1. Create a new Google Cloud project
  2. Enable the Google Calendar API
  3. Modify the OAuth consent screen
  4. Create an OAuth client ID credential
    • Download the credentials in JSON format and place them in your current directory as credentials.json.
  5. Run the application (using the command below), following the link to generate an OAuth token.
  6. Wait until the calendar is finished uploading!

To generate a Google Calendar:

$ python -m bhamcal <username> -f gcal -o <calendarId>

The Calendar ID can be found in the calendar-specific settings in the Google Calendar web view.

Legacy scraping method

In previous versions, bhamcal used to utilize a fully-fledged browser to make requests, using selenium. However, this approach (while still included in bhamcal) is much slower, so has been replaced by default.

If you want to use it, you'll need to install chromedriver to allow selenium to scrape the calendar data. To install it, see here, or for windows instructions, see below.

Additionally, you'll need to install some additional dependencies using pip:

$ pip3 install -e ".[browser]"

Then to invoke bhamcal using the chrome backend:

$ python3 -m bhamcal -o calendar.ics --downloader chrome

Windows

  • Download chromedriver.exe from here.
  • Put it inside C:\Windows.

Development

To develop, first set up a virtual environment and install the dependencies:

$ virtualenv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt

Then, you can run the tool using:

$ python -m bhamcal

If you add new dependencies, make sure that they are reflected in both requirements.txt and setup.py.

Docker

To build the Docker image:

$ docker build -t bhamcal .

To run it:

$ docker run -ti -v $(pwd):/data bhamcal

License

This project is licensed under the GPLv3. Enjoy! ๐ŸŽ‰

bhamcal's People

Contributors

jedevc avatar wrussell1999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.