diff --git a/auto-class-launcher-timetable.yaml b/auto-class-launcher-timetable.yaml new file mode 100644 index 0000000..b73d4ec --- /dev/null +++ b/auto-class-launcher-timetable.yaml @@ -0,0 +1,71 @@ +DBMS 💾: + link: 'https://meet.google.com/bvh-ixke-qxj?authuser=2' + times: + - day: mon + time: 9:00 + - day: wed + time: 15:00 + - day: thu + time: 9:00 + - day: fri + time: 9:00 + +DBMS Practice 💾: + link: https://meet.google.com/bvh-ixke-qxj?authuser=2 + times: + - day: mon + time: 14:00 + +Probability 🤥: + link: https://meet.google.com/vmu-krpk-cvr?authuser=2 + times: + - day: mon + time: 11:00 + - day: tue + time: 10:00 + - day: thu + time: 13:00 + - day: fri + time: 14:00 + +TOC - Youtubeeeeee 🎥: + link: https://www.youtube.com/channel/UCMcX0_nLyJkJ-C4bVvrEcmA + times: + - day: mon + time: 10:00 + - day: tue + time: 9:00 + - day: wed + time: 13:00 + - day: fri + time: 11:00 + +TOC Practical: + link: https://meet.google.com/fmv-yypx-ofe?authuser=2 + times: + - day: wed + time: 14:00 + +COA 😭: + link: https://meet.google.com/vuj-ccot-cxz?authuser=2 + times: + - day: mon + time: 13:00 + - day: tue + time: 11:00 + - day: thu + time: 11:00 + - day: fri + time: 13:00 + +COA Practise: + links: https://meet.google.com/vuj-ccot-cxz?authuser=2 + times: + - day: tue + time: 14:00 + +SPD 👩‍🦼: + links: https://teams.microsoft.com/_ + times: + - day: thu + time: 15:00 diff --git a/go.mod b/go.mod index 77bf17f..b01b4ed 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,9 @@ require ( ) require ( + github.com/ghodss/yaml v1.0.0 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 9803287..71f00e9 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -24,3 +26,6 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+R golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY= golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/main.go b/main.go index 35f31ed..a4302c2 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( _ "embed" - "encoding/json" "fmt" "net/url" "os" @@ -11,6 +10,7 @@ import ( "time" "github.com/fatih/color" + "github.com/ghodss/yaml" "github.com/skratchdot/open-golang/open" ) @@ -34,7 +34,7 @@ type ClassToday struct { var todaysClassLaunched map[string]bool -//go:embed sample.json +//go:embed sample.yaml var sampleConfigStr []byte func openClassLink(config ClassConfig) { @@ -106,16 +106,15 @@ func openClassLink(config ClassConfig) { } func main() { - - CONFIG_PATH := "./auto-class-launcher-timetable.json" + CONFIG_PATH := "./auto-class-launcher-timetable.yaml" var config ClassConfig // Now check if file exists if data, err := os.ReadFile(CONFIG_PATH); err == nil { - json.Unmarshal(data, &config) + yaml.Unmarshal(data, &config) } else if os.IsNotExist(err) { - json.Unmarshal([]byte(sampleConfigStr), &config) + yaml.Unmarshal([]byte(sampleConfigStr), &config) if os.WriteFile(CONFIG_PATH, sampleConfigStr, 0666) != nil { fmt.Println("Unable to create timetable on disk") diff --git a/sample.json b/sample.json deleted file mode 100644 index af10471..0000000 --- a/sample.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "DBMS 💾": { - "link": "https://meet.google.com/bvh-ixke-qxj?authuser=2", - "times": [ - { - "day": "mon", - "time": "9:00" - }, - { - "day": "wed", - "time": "15:00" - }, - { - "day": "thu", - "time": "9:00" - }, - { - "day": "fri", - "time": "9:00" - } - ] - }, - "DBMS Practice 💾": { - "link": "https://meet.google.com/bvh-ixke-qxj?authuser=2", - "times": [ - { - "day": "mon", - "time": "14:00" - } - ] - }, - "Probability 🤥": { - "link": "https://meet.google.com/vmu-krpk-cvr?authuser=2", - "times": [ - { - "day": "mon", - "time": "11:00" - }, - { - "day": "tue", - "time": "10:00" - }, - { - "day": "thu", - "time": "13:00" - }, - { - "day": "fri", - "time": "14:00" - } - ] - }, - "TOC - Youtubeeeeee 🎥": { - "link": "https://www.youtube.com/channel/UCMcX0_nLyJkJ-C4bVvrEcmA", - "times": [ - { - "day": "mon", - "time": "10:00" - }, - { - "day": "tue", - "time": "9:00" - }, - { - "day": "wed", - "time": "13:00" - }, - { - "day": "fri", - "time": "11:00" - } - ] - }, - "TOC Practical": { - "link": "https://meet.google.com/fmv-yypx-ofe?authuser=2", - "times": [ - { - "day": "wed", - "time": "14:00" - } - ] - }, - "COA 😭": { - "link": "https://meet.google.com/vuj-ccot-cxz?authuser=2", - "times": [ - { - "day": "mon", - "time": "13:00" - }, - { - "day": "tue", - "time": "11:00" - }, - { - "day": "thu", - "time": "11:00" - }, - { - "day": "fri", - "time": "13:00" - } - ] - }, - "COA Practise": { - "links": "https://meet.google.com/vuj-ccot-cxz?authuser=2", - "times": [ - { - "day": "tue", - "time": "14:00" - } - ] - }, - "SPD 👩‍🦼": { - "links": "https://teams.microsoft.com/_", - "times": [ - { - "day": "thu", - "time": "15:00" - } - ] - } -} diff --git a/sample.yaml b/sample.yaml new file mode 100644 index 0000000..b73d4ec --- /dev/null +++ b/sample.yaml @@ -0,0 +1,71 @@ +DBMS 💾: + link: 'https://meet.google.com/bvh-ixke-qxj?authuser=2' + times: + - day: mon + time: 9:00 + - day: wed + time: 15:00 + - day: thu + time: 9:00 + - day: fri + time: 9:00 + +DBMS Practice 💾: + link: https://meet.google.com/bvh-ixke-qxj?authuser=2 + times: + - day: mon + time: 14:00 + +Probability 🤥: + link: https://meet.google.com/vmu-krpk-cvr?authuser=2 + times: + - day: mon + time: 11:00 + - day: tue + time: 10:00 + - day: thu + time: 13:00 + - day: fri + time: 14:00 + +TOC - Youtubeeeeee 🎥: + link: https://www.youtube.com/channel/UCMcX0_nLyJkJ-C4bVvrEcmA + times: + - day: mon + time: 10:00 + - day: tue + time: 9:00 + - day: wed + time: 13:00 + - day: fri + time: 11:00 + +TOC Practical: + link: https://meet.google.com/fmv-yypx-ofe?authuser=2 + times: + - day: wed + time: 14:00 + +COA 😭: + link: https://meet.google.com/vuj-ccot-cxz?authuser=2 + times: + - day: mon + time: 13:00 + - day: tue + time: 11:00 + - day: thu + time: 11:00 + - day: fri + time: 13:00 + +COA Practise: + links: https://meet.google.com/vuj-ccot-cxz?authuser=2 + times: + - day: tue + time: 14:00 + +SPD 👩‍🦼: + links: https://teams.microsoft.com/_ + times: + - day: thu + time: 15:00