func cmd_short(c *command) bool { c.assertLeastNArg(1) db := openDb(c.dbinfo()) defer closeDb(db) attrs := fun.Keys(attrCommands).([]string) sort.Sort(sort.StringSlice(attrs)) ent, ok := c.oneEntity(db) if !ok { return false } tplName := sf("short_%s", ent.Type().String()) tpl.SetDB(db) c.tplExec(c.tpl(tplName), tpl.Args{E: ent, A: nil}) return true }
func renames( c *command, db *imdb.DB, files []string, entities []imdb.Entity, ) []string { var names []string tpl.SetDB(db) for i := range files { file, ent := files[i], entities[i] t := c.tpl(sf("rename_%s", ent.Type())) // If this file is a directory, don't both with extensions. stat, err := os.Stat(file) if err != nil { pef("%s", err) return nil } ext := path.Ext(file) if stat.IsDir() { ext = "" } buf := new(bytes.Buffer) attrs := tpl.Attrs{"Ext": ext, "ShowTv": flagRenameTvshowName} if err := t.Execute(buf, tpl.Args{E: ent, A: attrs}); err != nil { pef("%s", err) return nil } name := strings.TrimSpace(buf.String()) name = strings.Replace(name, "/", "_", -1) name = path.Join(path.Dir(file), name) names = append(names, name) } return names }
func (c *command) showAttr(db *imdb.DB, ent imdb.Entity, name string) bool { tpl.SetDB(db) c.tplExec(c.tpl(name), tpl.Args{E: ent, A: nil}) return true }