Ejemplo n.º 1
0
	filename string
}

// Extensions in regexp disabled atm since it prevents us from detecting folders
// var extensions string = "\\.(mkv|MKV|mp4|MP4|m4p|M4P|m4v|M4V|mpg|MPG|mpeg|MPEG|mp2|MP2|mpe|MPE|mpv|MPV|3gp|3GP|nsv|NSV|f4v|F4V|f4p|F4P|f4a|F4A|f4b|F4P|vob|VOB|avi|AVI|mov|MOV|wmv|WMV|asd|ASD|flv|FLV|ogv|OGV|ogg|OGG|qt|QT|yuv|YUV|rm|RM|rmvb|RMVB)"
var extensions string = ""
var spattern []string = []string{"(.*?)S(\\d{1,2})E(\\d{2})(.*)" + extensions,
	"(.*?)s(\\d{1,2})e(\\d{2})(.*)" + extensions,
	"(.*?)\\[?(\\d{1,2})x(\\d{2})\\]?(.*)" + extensions,
	"(.*?)Season.?(\\d{1,2}).*?Episode.?(\\d{1,2})(.*)" + extensions}
var mpattern []string = []string{"(.*?)\\((17[0-9][0-9]|180[0-9]|181[0-9]|18[2-9]\\d|19\\d\\d|2\\d{3}|30[0-3]\\d|304[0-8])\\)(.*)" + extensions,
	"(.*?)\\[(17[0-9][0-9]|180[0-9]|181[0-9]|18[2-9]\\d|19\\d\\d|2\\d{3}|30[0-3]\\d|304[0-8])\\](.*)" + extensions,
	"(.*?)\\{(17[0-9][0-9]|180[0-9]|181[0-9]|18[2-9]\\d|19\\d\\d|2\\d{3}|30[0-3]\\d|304[0-8])\\}(.*)" + extensions,
	"(.*?)(17[0-9][0-9]|180[0-9]|181[0-9]|18[2-9]\\d|19\\d\\d|2\\d{3}|30[0-3]\\d|304[0-8])(.*)" + extensions,
	"(.*?)(\\d{3,4}p)(.*)"}
var log *logger.Logger = logger.SetupNew("MAIN")

// Returns true if path exists
func exists(path string) bool {
	_, err := os.Stat(path)
	if err == nil {
		return true
	}
	if os.IsNotExist(err) {
		return false
	}
	return true
}

// Return true if path is a file
func isFile(path string) bool {
Ejemplo n.º 2
0
* Author: Amir Mofasser <*****@*****.**>
*	https://github.com/amimof
*
 */

import (
	logger "github.com/amimof/lazycopy/logger"
	"github.com/cheggaaa/pb"
	"io"
	"io/ioutil"
	"os"
	"path"
	"time"
)

var log *logger.Logger = logger.SetupNew("COPY")

// Copies a dir tree from src to dst. Overwrites content if ow is true
func CopyDir(src, dst string, ow bool) (int64, error) {

	// Stat source
	s, err := os.Stat(src)
	if err != nil {
		log.Error("Couldn't stat", src, err)
		return 0, err
	}

	// Ensure that src is a dir
	if !s.IsDir() {
		log.Error("Source is not a directory")
		return 0, err