Giter Site home page Giter Site logo

canvas-sync's Introduction

canvas-sync

CLI to download (course files, videos, etc) & view (deadlines, events, announcements) from Canvas

Contents

Install

Brew (mac/linux/wsl)

Brew is a package manager for macOS (or linux) that helps you install packages easily - more info here

To install Brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To install canvas-sync with Brew:

brew install aidanaden/tools/canvas-sync

Scoop (windows)

Scoop is a package manager for windows that helps you install programs from the command line (Brew but for windows) - more info here

To install Scoop, launch powershell and run:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex

To install canvas-sync with Scoop:

scoop bucket add scoop-bucket https://github.com/aidanaden/scoop-bucket.git
scoop install canvas-sync

You can also download directly from the releases page

Autocomplete (mac/linux/wsl)

Warning: skip if you don't know what zsh is

Run the following code block to add autocompletion for canvas-sync to your shell.

zsh

Code
echo "\n\nif type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"

  autoload -Uz compinit
  compinit
fi" >> ~/.zshrc && source ~/.zshrc

bash

Code
echo "if type brew &>/dev/null
then
  HOMEBREW_PREFIX="$(brew --prefix)"
  if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]
  then
    source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
  else
    for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*
    do
      [[ -r "${COMPLETION}" ]] && source "${COMPLETION}"
    done
  fi
fi" >> ~/.bash_profile && source ~/.bash_profile

fish (not necessary if you installed fish via homebrew)

Code
echo "if test -d (brew --prefix)"/share/fish/completions"
    set -gx fish_complete_path $fish_complete_path (brew --prefix)/share/fish/completions
end

if test -d (brew --prefix)"/share/fish/vendor_completions.d"
    set -gx fish_complete_path $fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
end" >> ~/.config/fish/config.fish && source ~/.config/fish/config.fish

Updating

Brew

If installed using brew, simply run:

canvas-sync upgrade

Scoop

If installed using scoop, simply run:

scoop update; scoop update canvas-sync

You can also download the latest version directly from the releases page

Set-up

To set up canvas-sync, run the init command:

canvas-sync init

init completed

  1. First, enter the directory to store all downloaded canvas data (files, videos, etc) e.g. $HOME/Desktop/canvas, if left blank all downloaded data will be stored in $HOME/canvas-sync/data

  2. Next, enter your school's canvas website url, if left blank it'll be set to https://canvas.nus.edu.sg (i'm from nus after all)

  3. You'll be asked for your username and password to log in to canvas (required for video downloads)

  4. After logging in, your config will be successfully created and all other commands will work, check them out here

Config

All configuration is done in the $HOME/canvas-sync/config.yaml file.

4 values can be configured:

  • data_dir: directory to store downloaded canvas data, defaults to $HOME/canvas-sync/data
  • canvas_url: URL of your target canvas site, defaults to https://canvas.nus.edu.sg
  • canvas_username: your canvas site username
  • canvas_password: your canvas site password
  • access_token (DO NOT EDIT): token generated by the init command to download from canvas directly, if not filled you'll need to run canvas-sync init

To create a config file, run canvas-sync init

Commands

Init

Creates a new config file in the default directory $HOME/canvas-sync

init

Pull

Downloads data (files, videos, etc) from canvas, overwrites all existing data

Pull Files

pull files demo

View documentation via pull files -h

Pull Videos

pull videos demo

View documentation via pull videos -h

Update

Updates downloaded data (files, videos, etc) from canvas

Update Files

update files demo

View documentation via update files -h

Update Videos

update videos demo

View documentation via update videos -h

View

Display data from canvas (deadlines, events, announcements, etc)

View Deadlines (assignments)

Display past/future assignment deadlines

view deadlines demo

View Events (Announcements/lectures/tutorials)

Display past/future lectures/announcements

view events demo

View People (from a given course)

Display people from a given course code

view people demo

FAQ

What is this $HOME thing? It's the main directory of the current user. For mac/linux it'll be `/Users/`, for windows it'll be `C:\Users\`
It doesn't work for my university This tool was built by an NUS student (me), hence i'm not able to test it with canvas sites from any other university. Please create an issue at https://github.com/aidanaden/canvas-sync/issues regarding any problems you face with your school's canvas website. Thank you! :)
Is my username/password stored anywhere? No, we do not store any credentials. When running the `init` command, the tool logs in to your canvas website and creates an access token that allows the tool to access your canvas data on your behalf.

If there are any other questions, please create an issue here, if it's a common enough issue i'll add it to the FAQ section here :)

LICENSE

MIT

canvas-sync's People

Contributors

733amir avatar aidanaden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

canvas-sync's Issues

feat: init process via canvas login

new init process:

  1. location to store downloaded data
  2. canvas url
  3. select auth method:
    • generate access token (login required only once)
      • login process (username, password)
      • save access token locally (config file)
    • login (login required periodically)
      • login process (username, password)
      • save cookies locally (cookes file)
  4. success

feat: `upgrade` command

single command to update canvas-sync across all install methods

check brew, snap, scoop locations to determine install method, run update commands based on install method

if direct download, print warning message telling user to download newest version

docs: add warning when using browser login on mac

Issue

when logging in via browser on mac, browser cookies are extracted for canvas.nus.edu.sg which will trigger mac's warning system prompting user to enter their password for permission.

Temporary solution

  • add warning in docs

Proper solution

  • login to canvas.nus.edu.sg programmatically, prompting user for their username + password and then storing the cookies when authenticated

feat: download videos

requires reverse-engineering the fluminurs git repo, unsure if even possible tbh but would require quite a bit of work

feat: proper ci testing

Issue

no ci/testing is done currently, which means manual testing is required before every release (very unreliable cuz im retarded)

Proposal

create ci testing and check the expected output from the terminal - if any unexpected error appears, break test

there should be a terminal testing library out there that does this

feat: store people after first view

Issue

currently every view people command makes a query for the first 100 users in a given course

Proposal

store all students in the data_dir specified in a .csv file, and display values from the stored csv file on all subsequent queries

this allows viewing of all students in a course without excessively querying the api endpoint

feat: credit command

Incentivise PRs, contributions, beta testers by adding a credits command which prints the username of all recent contributors/beta testers

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.