Skip to content
Permalink
Browse files

Using glide

  • Loading branch information...
s32x committed Jun 25, 2018
1 parent c1cb061 commit 9125cc2da83f83cac2af686badcc41ec2404cf12
Showing 998 changed files with 95 additions and 304,230 deletions.
@@ -1 +1 @@
/vendor/*
/vendor
@@ -1,10 +1,10 @@
The MIT License (MIT)
=====================

Copyright 2017 Steven Wolfe
Copyright 2018 Steven Wolfe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
NOVENDOR_PATH = $$(glide novendor)
.PHONY: test

glide:
-rm glide.lock
-rm -r vendor
glide cache-clear
glide install

test:
go clean
go test ${NOVENDOR_PATH}

install:
go install

run:
go run main.go
@@ -3,7 +3,6 @@ package anirip
import (
"errors"
"fmt"
"github.com/robertkrimen/otto"
"io"
"io/ioutil"
"math/rand"
@@ -14,6 +13,14 @@ import (
"strconv"
"strings"
"time"

"github.com/entrik/httpclient"
"github.com/robertkrimen/otto"
)

const (
uaList = "https://raw.githubusercontent.com/cvandeplas/pystemon/master/user-agents.txt"
defaultUA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"
)

// HTTPClient performs
@@ -25,30 +32,36 @@ type HTTPClient struct {
// NewHTTPClient generates a new HTTPClient Requester that contains a random
// user-agent to emulate browser requests
func NewHTTPClient() (*HTTPClient, error) {
resp, err := http.Get("https://raw.githubusercontent.com/cvandeplas/pystemon/master/user-agents.txt")
if err != nil {
return nil, err
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}

// Create the client and attach a cookie jar
client := &http.Client{}
client.Jar, _ = cookiejar.New(nil)

// Splits the user-agents into a slice and returns an HTTPClient with a random
// user-agent on the header
ua := strings.Split(string(b), "\n")
rand.Seed(time.Now().UnixNano())
return &HTTPClient{
Client: client,
UserAgent: ua[rand.Intn(len(ua))],
UserAgent: randomUA(),
}, nil
}

// randomUA retrieves a list of user-agents and returns
// a one randomly selected from the list
func randomUA() string {
// Seed the random number generator
rand.Seed(time.Now().UnixNano())

// Retrieve the bytes of the user-agent list
useragents, err := httpclient.GetString(uaList)
if err != nil {
return defaultUA
}

// Split all user-agents into a slice and return a
// single random one
ua := strings.Split(useragents, "\n")
if len(ua) == 0 {
return defaultUA
}
return ua[rand.Intn(len(ua))]
}

// Post performs a POST request using the passed url and body using the
// in-memory HTTPClient
func (c *HTTPClient) Post(url string, header http.Header, body io.Reader) (*http.Response, error) {
@@ -23,6 +23,6 @@ type Episodes []Episode
type Episode interface {
GetEpisodeInfo(client *HTTPClient, quality string) error
Download(vp VideoProcessor) error
DownloadSubtitles(client *HTTPClient, language string, tempDir string) (string, error)
DownloadSubtitles(client *HTTPClient, language, tempDir string) (string, error)
GetFilename() string
}

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1 @@
package: github.com/sdwolfe32/anirip
@@ -1,9 +1,10 @@
package main

import (
"os"

"github.com/sdwolfe32/anirip/anirip"
"github.com/sdwolfe32/anirip/crunchyroll"
"os"
)

var (

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 9125cc2

Please sign in to comment.
You can’t perform that action at this time.