本文整理汇总了Golang中github.com/jbrodriguez/mlog.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Start
func (d *Dal) Start() {
mlog.Info("Starting service Dal ...")
dbPath := filepath.Join(d.settings.DataDir, "mediagui.db")
var err error
d.db, err = sql.Open("sqlite3", dbPath)
if err != nil {
mlog.Fatalf("Unable to open database (%s): %s", dbPath, err)
}
d.mailbox = d.register(d.bus, "/get/movies/cover", d.getCover)
d.registerAdditional(d.bus, "/get/movies", d.getMovies, d.mailbox)
d.registerAdditional(d.bus, "/get/movies/duplicates", d.getDuplicates, d.mailbox)
d.registerAdditional(d.bus, "/command/movie/exists", d.checkExists, d.mailbox)
d.registerAdditional(d.bus, "/command/movie/store", d.storeMovie, d.mailbox)
d.registerAdditional(d.bus, "/command/movie/partialstore", d.partialStoreMovie, d.mailbox)
d.registerAdditional(d.bus, "/command/movie/update", d.updateMovie, d.mailbox)
d.registerAdditional(d.bus, "/command/movie/delete", d.deleteMovie, d.mailbox)
d.registerAdditional(d.bus, "/put/movies/score", d.setScore, d.mailbox)
d.registerAdditional(d.bus, "/put/movies/watched", d.setWatched, d.mailbox)
d.countRows = d.prepare("select count(*) from movie;")
mlog.Info("Connected to database %s", dbPath)
go d.react()
}
示例2: Execute
func (s *ReScrape) Execute(wid int) {
movie := s.dto.Movie.(*model.Movie)
// lib.Notify(s.bus, "import:progress", fmt.Sprintf("RESCRAPE REQUESTED (%d) [%d] %s", wid, movie.Id, movie.Title))
mlog.Info("RESCRAPE REQUESTED (%d) [%d] %s", wid, movie.Id, movie.Title)
now := time.Now().UTC().Format(time.RFC3339)
movie.Modified = now
id := movie.Tmdb_Id
err := _scrape(wid, s.tmdb, id, movie)
if err != nil {
// lib.Notify(s.bus, "import:progress", fmt.Sprintf("RESCRAPE FAILED (%d) [%d] %s: %s", wid, movie.Id, movie.Title, err))
mlog.Warning("RESCRAPE FAILED (%d) [%d] %s: %s", wid, movie.Id, movie.Title, err)
s.bus.Pub(nil, "/event/workunit/done")
return
}
s.dto.BaseUrl = s.tmdb.BaseUrl
s.dto.SecureBaseUrl = s.tmdb.SecureBaseUrl
// lib.Notify(s.bus, "import:progress", fmt.Sprintf("RESCRAPE COMPLETED (%d) [%d] %s", wid, movie.Id, movie.Title))
mlog.Info("RESCRAPE COMPLETED (%d) [%d] %s", wid, movie.Id, movie.Title)
msg := &pubsub.Message{Payload: s.dto}
s.bus.Pub(msg, "/event/movie/rescraped")
}
示例3: setScore
func (d *Dal) setScore(msg *pubsub.Message) {
movie := msg.Payload.(*model.Movie)
mlog.Info("STARTED UPDATING MOVIE SCORE [%d] %s (%d)", movie.Id, movie.Title, movie.Score)
tx, err := d.db.Begin()
if err != nil {
mlog.Fatalf("at begin: %s", err)
}
stmt, err := tx.Prepare(`update movie set
score = ?,
modified = ?
where rowid = ?`)
if err != nil {
tx.Rollback()
mlog.Fatalf("at prepare: %s", err)
}
defer stmt.Close()
now := time.Now().UTC().Format(time.RFC3339)
_, err = stmt.Exec(movie.Score, now, movie.Id)
if err != nil {
tx.Rollback()
mlog.Fatalf("at exec: %s", err)
}
tx.Commit()
mlog.Info("FINISHED UPDATING MOVIE SCORE [%d] %s", movie.Id, movie.Title)
msg.Reply <- movie
}
示例4: updateMovie
func (d *Dal) updateMovie(msg *pubsub.Message) {
defer d.bus.Pub(nil, "/event/workunit/done")
movie := msg.Payload.(*model.Movie)
mlog.Info("STARTED UPDATING [%d] %s", movie.Id, movie.Title)
tx, err := d.db.Begin()
if err != nil {
mlog.Fatalf("at begin: %s", err)
}
stmt, err := tx.Prepare(`update movie set title = ?,
original_title = ?,
year = ?,
runtime = ?,
tmdb_id = ?,
imdb_id = ?,
overview = ?,
tagline = ?,
cover = ?,
backdrop = ?,
genres = ?,
vote_average = ?,
vote_count = ?,
countries = ?,
modified = ?,
director = ?,
writer = ?,
actors = ?,
awards = ?,
imdb_rating = ?,
imdb_votes = ?
where rowid = ?`)
if err != nil {
tx.Rollback()
mlog.Fatalf("at prepare: %s", err)
}
defer stmt.Close()
_, err = stmt.Exec(movie.Title, movie.Original_Title, movie.Year, movie.Runtime, movie.Tmdb_Id, movie.Imdb_Id, movie.Overview, movie.Tagline, movie.Cover, movie.Backdrop, movie.Genres, movie.Vote_Average, movie.Vote_Count, movie.Production_Countries, movie.Modified, movie.Director, movie.Writer, movie.Actors, movie.Awards, movie.Imdb_Rating, movie.Imdb_Votes, movie.Id)
if err != nil {
tx.Rollback()
mlog.Fatalf("at exec: %s", err)
}
tx.Commit()
mlog.Info("FINISHED UPDATING [%d] %s", movie.Id, movie.Title)
// updated := &pubsub.Message{}
// d.bus.Pub(updated, "/event/movie/updated")
}
示例5: Start
func (s *Scanner) Start() {
mlog.Info("Starting service Scanner ...")
s.mailbox = s.register(s.bus, "/command/movie/scan", s.scanMovies)
s.registerAdditional(s.bus, "/event/config/changed", s.configChanged, s.mailbox)
re := []string{
`(?i)(.*)/(?P<Resolution>.*?)/(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)/(?:.*/)*bdmv/index.(?P<FileType>bdmv)$`,
`(?i)(.*)/(?P<Resolution>.*?)/(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)/(?:.*/)*.*\.(?P<FileType>iso|img|nrg|mkv|avi|xvid|ts|mpg|dvr-ms|mdf|wmv|mp4)$`,
`(?i)(.*)/(?P<Resolution>.*?)/(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)/(?:.*/)*(?:video_ts|hv000i01)\.(?P<FileType>ifo)$`,
// `(?i)(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)/(?:.*/)*bdmv/index.(?P<FileType>bdmv)$`,
// `(?i)(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)/(?:.*/)*.*\.(?P<FileType>iso|img|nrg|mkv|avi|xvid|ts|mpg|dvr-ms|mdf|wmv)$`,
// `(?i)(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)/(?:.*/)*(?:video_ts|hv000i01)\.(?P<FileType>ifo)$`,
// `(?i)(?P<Name>.*?)\s\((?P<Year>\d\d\d\d)\)\.(?P<FileType>iso|img|nrg|mkv|avi|xvid|ts|mpg|dvr-ms|mdf|wmv)$`,
}
s.re = make([]*lib.Rexp, 0)
for _, regex := range re {
s.re = append(s.re, &lib.Rexp{Exp: regexp.MustCompile(regex)})
}
s.includedMask = ".bdmv|.iso|.img|.nrg|.mkv|.avi|.xvid|.ts|.mpg|.dvr-ms|.mdf|.wmv|.ifo|.mp4"
// cmd.Init()
go s.react()
}
示例6: analyze
func (s *Scanner) analyze(files []string) {
mlog.Info("Found %d files", len(files))
for _, file := range files {
// comparePath := strings.TrimPrefix(path, file)
// mlog.Info("folder: %s, comparePath: %s", folder, comparePath)
// TODO: remove folder from path to match against rexp
for i := 0; i < 3; i++ {
rmap := s.re[i].Match(file)
if rmap == nil {
continue
}
resolution, ok := rmap["Resolution"]
if !ok {
resolution = ""
}
movie := &model.Movie{Title: rmap["Name"], File_Title: rmap["Name"], Year: rmap["Year"], Resolution: resolution, FileType: rmap["FileType"], Location: file}
// mlog.Info("FOUND [%s] (%s)", movie.Title, movie.Location)
// mlog.Info("found %s", movie.Location)
msg := &pubsub.Message{Payload: movie}
s.bus.Pub(msg, "/event/movie/found")
// self.Bus.MovieFound <- movie
}
}
}
示例7: Start
func (c *Core) Start() {
mlog.Info("Starting service Core ...")
c.mailbox = c.register(c.bus, "/get/config", c.getConfig)
c.registerAdditional(c.bus, "/post/import", c.importMovies, c.mailbox)
c.registerAdditional(c.bus, "/post/prune", c.pruneMovies, c.mailbox)
c.registerAdditional(c.bus, "/put/config/folder", c.addMediaFolder, c.mailbox)
c.registerAdditional(c.bus, "/put/movies/fix", c.fixMovie, c.mailbox)
c.registerAdditional(c.bus, "/event/movie/found", c.doMovieFound, c.mailbox)
c.registerAdditional(c.bus, "/event/movie/tmdbnotfound", c.doMovieTmdbNotFound, c.mailbox)
c.registerAdditional(c.bus, "/event/movie/scraped", c.doMovieScraped, c.mailbox)
c.registerAdditional(c.bus, "/event/movie/rescraped", c.doMovieReScraped, c.mailbox)
// c.registerAdditional(c.bus, "/event/movie/updated", c.doMovieUpdated, c.mailbox)
// c.registerAdditional(c.bus, "/event/movie/cached/forced", c.doMovieCachedForced, c.mailbox)
c.registerAdditional(c.bus, "/event/workunit/done", c.doWorkUnitDone, c.mailbox)
c.re = regexp.MustCompile(`(?i)/Volumes/(.*?)/.*`)
c.maps = make(map[string]bool)
// maps["/Volumes/wopr-films"] = true // for example
for _, folder := range c.settings.MediaFolders {
c.maps[folder] = false
if _, err := os.Stat(folder); err == nil {
c.maps[folder] = true
}
}
go c.react()
}
示例8: partialStoreMovie
func (d *Dal) partialStoreMovie(msg *pubsub.Message) {
defer d.bus.Pub(nil, "/event/workunit/done")
movie := msg.Payload.(*model.Movie)
// d.count = 0
now := time.Now().UTC().Format(time.RFC3339)
movie.Added = now
movie.Modified = now
mlog.Info("STARTED PARTIAL SAVING %s", movie.Title)
tx, err := d.db.Begin()
if err != nil {
mlog.Fatalf("at begin: %s", err)
}
stmt, err := tx.Prepare(`insert into movie(title, original_title, file_title,
year, runtime, tmdb_id, imdb_id, overview, tagline,
resolution, filetype, location, cover, backdrop, genres,
vote_average, vote_count, countries, added, modified,
last_watched, all_watched, count_watched, score, director,
writer, actors, awards, imdb_rating, imdb_votes)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
if err != nil {
tx.Rollback()
mlog.Fatalf("at prepare: %s", err)
}
defer stmt.Close()
_, err = stmt.Exec(movie.Title, movie.Original_Title, movie.File_Title, movie.Year,
movie.Runtime, movie.Tmdb_Id, movie.Imdb_Id, movie.Overview, movie.Tagline,
movie.Resolution, movie.FileType, movie.Location, movie.Cover, movie.Backdrop,
movie.Genres, movie.Vote_Average, movie.Vote_Count, movie.Production_Countries,
movie.Added, movie.Modified, movie.Last_Watched, movie.All_Watched, movie.Count_Watched,
movie.Score, movie.Director, movie.Writer, movie.Actors, movie.Awards, movie.Imdb_Rating,
movie.Imdb_Votes)
if err != nil {
tx.Rollback()
mlog.Fatalf("at exec: %s", err)
}
tx.Commit()
mlog.Info("FINISHED PARTIAL SAVING %s [%d]", movie.Title, movie.Id)
}
示例9: listMovies
func (d *Dal) listMovies(options *lib.Options) (total uint64, movies []*model.Movie) {
// mlog.Info("listMovies.options: %+v", options)
tx, err := d.db.Begin()
if err != nil {
mlog.Fatalf("listMovies:Unable to begin transaction: %s", err)
}
sql := fmt.Sprintf(`select rowid, title, original_title, file_title, year, runtime, tmdb_id, imdb_id,
overview, tagline, resolution, filetype, location, cover, backdrop, genres, vote_average,
vote_count, countries, added, modified, last_watched, all_watched, count_watched, score,
director, writer, actors, awards, imdb_rating, imdb_votes
from movie order by %s %s, rowid desc limit ? offset ?`, options.SortBy, options.SortOrder)
stmt, err := tx.Prepare(sql)
if err != nil {
mlog.Fatalf("Unable to prepare transaction: %s", err)
}
defer stmt.Close()
rows, err := stmt.Query(options.Limit, options.Offset)
if err != nil {
mlog.Fatalf("Unable to prepare transaction: %s", err)
}
items := make([]*model.Movie, 0)
// if options.Offset == 0 {
// if d.count == 0 {
var count uint64
err = d.countRows.QueryRow().Scan(&count)
if err != nil {
mlog.Fatalf("Unable to count rows: %s", err)
}
// }
for rows.Next() {
movie := model.Movie{}
rows.Scan(
&movie.Id, &movie.Title, &movie.Original_Title, &movie.File_Title, &movie.Year,
&movie.Runtime, &movie.Tmdb_Id, &movie.Imdb_Id, &movie.Overview, &movie.Tagline,
&movie.Resolution, &movie.FileType, &movie.Location, &movie.Cover, &movie.Backdrop,
&movie.Genres, &movie.Vote_Average, &movie.Vote_Count, &movie.Production_Countries,
&movie.Added, &movie.Modified, &movie.Last_Watched, &movie.All_Watched,
&movie.Count_Watched, &movie.Score, &movie.Director, &movie.Writer, &movie.Actors,
&movie.Awards, &movie.Imdb_Rating, &movie.Imdb_Votes,
)
items = append(items, &movie)
}
rows.Close()
tx.Commit()
mlog.Info("Listed %d movies (total %d)", len(items), count)
return count, items
}
示例10: Start
func (c *Cache) Start() {
mlog.Info("Starting service Cache ...")
c.mailbox = c.register(c.bus, "/command/movie/cache", c.cacheMovie)
c.pool = lib.NewPool(4, 2000)
go c.react()
}
示例11: getDuplicates
func (d *Dal) getDuplicates(msg *pubsub.Message) {
mlog.Info("getDuplicates.starting")
tx, err := d.db.Begin()
if err != nil {
mlog.Fatalf("Unable to begin transaction: %s", err)
}
// rows, err := self.listMovies.Query()
// if err != nil {
// mlog.Fatalf("unable to prepare transaction: %s", err)
// }
// rows, err := self.db.Query("select rowid, title, original_title, file_title, year, runtime, tmdb_id, imdb_id, overview, tagline, resolution, filetype, location, cover, backdrop, genres, vote_average, vote_count, countries, added, modified, last_watched, all_watched, count_watched from movie where title in (select title from movie group by title having count(*) > 1);")
rows, err := d.db.Query(`select a.rowid, a.title, a.original_title, a.file_title,
a.year, a.runtime, a.tmdb_id, a.imdb_id, a.overview, a.tagline, a.resolution,
a.filetype, a.location, a.cover, a.backdrop, a.genres, a.vote_average,
a.vote_count, a.countries, a.added, a.modified, a.last_watched, a.all_watched,
a.count_watched, a.score, a.director, a.writer, a.actors, a.awards, a.imdb_rating,
a.imdb_votes
from
movie a
join
(select title, year from movie group by title, year having count(*) > 1) b
on a.title = b.title and a.year = b.year;`)
if err != nil {
mlog.Fatalf("Unable to prepare transaction: %s", err)
}
items := make([]*model.Movie, 0)
for rows.Next() {
movie := model.Movie{}
rows.Scan(&movie.Id, &movie.Title, &movie.Original_Title, &movie.File_Title, &movie.Year, &movie.Runtime, &movie.Tmdb_Id, &movie.Imdb_Id, &movie.Overview, &movie.Tagline, &movie.Resolution, &movie.FileType, &movie.Location, &movie.Cover, &movie.Backdrop, &movie.Genres, &movie.Vote_Average, &movie.Vote_Count, &movie.Production_Countries, &movie.Added, &movie.Modified, &movie.Last_Watched, &movie.All_Watched, &movie.Count_Watched, &movie.Score, &movie.Director, &movie.Writer, &movie.Actors, &movie.Awards, &movie.Imdb_Rating, &movie.Imdb_Votes)
items = append(items, &movie)
}
rows.Close()
tx.Commit()
mlog.Info("Found %d duplicate movies", len(items))
msg.Reply <- &model.MoviesDTO{Total: uint64(len(items)), Items: items}
}
示例12: addMediaFolder
func (c *Core) addMediaFolder(msg *pubsub.Message) {
folder := msg.Payload.(string)
mlog.Info("addMediaFolder: %s", folder)
c.settings.MediaFolders = append(c.settings.MediaFolders, folder)
c.settings.Save()
cfg := &pubsub.Message{Payload: c.settings}
c.bus.Pub(cfg, "/event/config/changed")
msg.Reply <- &c.settings.Config
// mlog.Info("Sent config")
}
示例13: getMovies
func (d *Dal) getMovies(msg *pubsub.Message) {
options := msg.Payload.(*lib.Options)
mlog.Info("options: %+v", options)
var total uint64
var items []*model.Movie
if options.Query == "" {
total, items = d.listMovies(options)
} else {
total, items = d.searchMovies(options)
}
msg.Reply <- &model.MoviesDTO{Total: total, Items: items}
}
示例14: Start
func (s *Scraper) Start() {
mlog.Info("Starting service Scraper ...")
var err error
s.tmdb, err = tmdb.NewClient("e610ded10c3f47d05fe797961d90fea6", false)
if err != nil {
mlog.Fatalf("Unable to create tmdb client: %s", err)
}
s.mailbox = s.register(s.bus, "/command/movie/scrape", s.scrapeMovie)
s.registerAdditional(s.bus, "/command/movie/rescrape", s.reScrapeMovie, s.mailbox)
s.registerAdditional(s.bus, "/event/config/changed", s.configChanged, s.mailbox)
s.pool = lib.NewPool(12, 4000)
go s.react()
}
示例15: walk
func (s *Scanner) walk(folder string) error {
if folder[len(folder)-1] != '/' {
folder = folder + "/"
}
err := filepath.Walk(folder, func(path string, f os.FileInfo, err error) error {
if err != nil {
mlog.Info("scanner.walk: %s (%s) - [%+v]", err, path, f)
}
if !strings.Contains(s.includedMask, strings.ToLower(filepath.Ext(path))) {
// mlog.Info("[%s] excluding %s", filepath.Ext(path), path)
return nil
}
// comparePath := strings.TrimPrefix(path, folder)
// mlog.Info("folder: %s, comparePath: %s", folder, comparePath)
// TODO: remove folder from path to match against rexp
for i := 0; i < 3; i++ {
var rmap = s.re[i].Match(path)
if rmap == nil {
continue
}
var resolution string
var ok bool
if resolution, ok = rmap["Resolution"]; !ok {
resolution = ""
}
movie := &model.Movie{Title: rmap["Name"], File_Title: rmap["Name"], Year: rmap["Year"], Resolution: resolution, FileType: rmap["FileType"], Location: path}
// mlog.Info("FOUND [%s] (%s)", movie.Title, movie.Location)
msg := &pubsub.Message{Payload: movie}
s.bus.Pub(msg, "/event/movie/found")
// self.Bus.MovieFound <- movie
return nil
}
return nil
})
return err
}