Example #1
0
}

func NewCrawler(client *http.Client) *Crawler {
	return &Crawler{
		client,
	}
}

type CrawlerConfig struct {
	Keyword   string    `json:"keyword"`
	Category  string    `json:"category"`
	Scope     int       `json:"scope"`
	CreatedAt time.Time `json:"created_at"`
}

var CrawlerConfigValidator = v.NewObjectValidator()

func init() {
	CrawlerConfigValidator.Field("Keyword").Required()
	CrawlerConfigValidator.Field("Category").Required()
}

const FEED_SCOPE_ALL = 0
const FEED_SCOPE_TERRESTRIAL = 1
const FEED_SCOPE_BS = 2
const FEED_SCOPE_CS = 5
const FEED_SCOPE_CS_PREMIUM = 4
const feed_url_template = "http://tv.so-net.ne.jp/rss/schedulesBySearch.action?stationPlatformId=%d&condition.keyword=%s"
const iepg_url_template = "http://tv.so-net.ne.jp/iepg.tvpid?id=%s"

func (c *Crawler) GetIEpgList(keyword string, scope int) ([]string, error) {
Example #2
0
package tv

import (
	"fmt"
	"github.com/speedland/apps/lib/util"
	"github.com/speedland/wcg"
	v "github.com/speedland/wcg/validation"
	"time"
)

var MaxRecordTime = 24 * time.Hour
var MinRecordTime = 1 * time.Minute
var RecordValidator = v.NewObjectValidator()
var InvalidChars = "[\x00-\x1F\x22-\x27\x2a-\x2c\x2f]"
var ValidUUID = "^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$"

type Record interface {
	Key() string
	Start() error
	Stop() error
	IsRunning() bool
	StartAt() time.Time
	EndAt() time.Time
	CheckInterval() time.Duration
}

type RecordState int

var (
	RSWaiting   = RecordState(1)
	RSRecording = RecordState(2)
Example #3
0
package tv

import (
	"fmt"
	v "github.com/speedland/wcg/validation"
)

type TvChannel struct {
	Cid           string `json:"cid"`
	Sid           string `json:"sid"`
	Name          string `json:"name"`
	IEpgStationId string `json:"iepg_station_id"`
}

var TvChannelValidator = v.NewObjectValidator()

func init() {
	TvChannelValidator.Field("Sid").Required()
	TvChannelValidator.Field("Cid").Required()
	TvChannelValidator.Field("Name").Required()
}

func (c *TvChannel) Key() string {
	return fmt.Sprintf("%s.%s", c.Cid, c.Sid)
}

func (c *TvChannel) String() string {
	return fmt.Sprintf("<TvChannelConfig : [%s] %s>", c.Key(), c.Name)
}