~nature/yt-cli

097a8dc2f7a7f51d98489fa52950394e55752347 — LordNature 1 year, 5 months ago b58a251
main.go: Ran `go fmt` for clean-up.
1 files changed, 14 insertions(+), 14 deletions(-)

M main.go
M main.go => main.go +14 -14
@@ 1,28 1,28 @@
package main

import (
	"encoding/xml"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"net/http"
	"encoding/xml"
	"io/ioutil"
	"fmt"
	"os"
	"strings"
	"text/tabwriter"
)

type Channel struct {
	ID string `xml:"yt:channelId"`
	Name string `xml:"title"`
	ID     string  `xml:"yt:channelId"`
	Name   string  `xml:"title"`
	Videos []Video `xml:"entry"`
}

type Video struct {
	XMLName xml.Name `xml:"entry"`
	ID string `xml:"videoId"`
	Title string `xml:"title"`
	Date string `xml:"published"`
	ID      string   `xml:"videoId"`
	Title   string   `xml:"title"`
	Date    string   `xml:"published"`
}

var CONFIG_DIR string


@@ 44,7 44,7 @@ func init() {

	// Check if config file exits
	if _, err = os.Stat(configDir + "/channels"); os.IsNotExist(err) {
		err = ioutil.WriteFile(configDir + "/channels", nil, 0600)
		err = ioutil.WriteFile(configDir+"/channels", nil, 0600)
		if err != nil {
			log.Fatal(err)
			return


@@ 56,8 56,6 @@ func init() {

}



func main() {
	// set flags
	var add = flag.String("add", "", "Add a channel to subscription list.")


@@ 95,7 93,9 @@ func main() {
				panic(err)
			}
			for i, v := range ch.Videos {
				if i > 4 { break }
				if i > 4 {
					break
				}
				fmt.Fprintf(w, "[%.10s]\t%.20s\t- %.50s\t(%.12s)\n", v.Date, ch.Name, v.Title, v.ID)
			}
		}


@@ 106,7 106,7 @@ func main() {
// Appends subscription to file
func addSub(id string) (err error) {
	// Open file in append mode only
	file, err := os.OpenFile(CONFIG_DIR + "/channels", os.O_APPEND|os.O_WRONLY, 0600)
	file, err := os.OpenFile(CONFIG_DIR+"/channels", os.O_APPEND|os.O_WRONLY, 0600)
	if err != nil {
		return
	}