Пример #1
0
func DelImageByLocation(location string) error {

	if row, err := Engine.Where("location=?", helper.Local2url(location)).Delete(new(Image)); err != nil || row == 0 {
		fmt.Println("row:", row)
		fmt.Println("DelImageBylocation删除话题错误:", err)
		return err
	} else {
		return nil
	}

}
Пример #2
0
Файл: mgr.go Проект: rose312/mzr
func main() {

	if imgs, e := GetSpiderData(0, 0, "id"); e == nil {
		for k, v := range *imgs {
			fmt.Println("#", k, ":", v.Url)
			if fpath, err := Download(v.Url); err == nil {
				fmt.Println("fpath:", fpath)
				fmt.Println(helper.Local2url(fpath))
				if thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, e := helper.MakeThumbnails(helper.Local2url(fpath)); e == nil {

					title := "清新系 美女季 2013年度/第" + fmt.Sprint(time.Now().Format("0102-150405")) + "期"
					id, err := AddTopic(title, "<p><img src=\""+helper.Local2url(fpath)+"\" alt=\""+title+"\"/></p>", thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, 1, 1, 1)
					if err != nil {
						fmt.Println("###################发布话题", id, "出错####################", err)
					}
				} else {
					fmt.Println("@@@@@@@@@@@@@@@处理缩略图出错@@@@@@@@@@@@@@@@", err)
				}
			}
		}

	}

}
Пример #3
0
func AddImage(path string, pid int64, ctype int64, uid int64) (int64, error) {
	fg, err := helper.GetImagePha(helper.Url2local(path))
	if err != nil {
		return -1, err
	}

	img := new(Image)
	img.Ctype = ctype
	img.Uid = uid
	img.Created = time.Now()
	img.Location = helper.Local2url(path)
	img.Fingerprint = fg
	img.Pid = pid
	return Engine.Insert(img)

}
Пример #4
0
Файл: mzs.go Проект: rose312/mzr
func main() {
	urls := []string{}
	//循环所有页面查找所有图片的网页链接
	for i := 1; i <= 50; i++ {
		x, _ := goquery.NewDocument("http://www.mzitu.com/page/" + strconv.Itoa(i))
		x.Find(".imageLink").Each(func(idx int, s *goquery.Selection) {
			v, b := s.Attr("href")
			if b == true {
				urls = append(urls, v)
			}
		})
	}

	//遍历所有图片网址 提取图片URL后保存到数据库
	for k, v := range urls {

		fmt.Println("<url #[", k, "]# url>")
		SelfPage(v) //单独处理网页
	}

	//读取图片集合并下载
	if imgs, e := GetSpiderData(0, 0, "id"); e == nil {
		j := int64(0)
		for k, v := range *imgs {
			fmt.Println("#>", k, ":", v.Url)
			if fpath, err := Download(v.Url); err == nil {
				fmt.Println("fpath:", fpath)
				fmt.Println(helper.Local2url(fpath))

				if helper.Exist(fpath) {
					if thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, e := helper.MakeThumbnails(helper.Local2url(fpath)); thumbnails != "" && thumbnailslarge != "" && thumbnailsmedium != "" && thumbnailssmall != "" && e == nil {
						j += 1
						title := "性感系 " + v.Title + " 美女季/第" + fmt.Sprint(time.Now().Format("0102-150405")) + "期"
						cid := int64(1)
						nid := int64(4) //2
						uid := int64(1)
						role := int64(-1000)
						if 1899 < j <= 3541 {
							model.DelTopic(j, uid, role)
							id, err := UpdateTopic(j, title, "<p><img src=\""+helper.Local2url(fpath)+"\" alt=\""+v.Title+"\"/></p>", thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, cid, nid, uid)
							if err != nil {
								fmt.Println("###################发布话题", id, "出错####################", err)
							}
						} else {

							id, err := AddTopic(title, "<p><img src=\""+helper.Local2url(fpath)+"\" alt=\""+v.Title+"\"/></p>", thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, cid, nid, uid)
							if err != nil {
								fmt.Println("###################发布话题", id, "出错####################", err)
							}
						}
					} else {
						fmt.Println("@@@@@@@@@@@@@@@处理缩略图出错@@@@@@@@@@@@@@@@", err)
						os.Remove(fpath)
						os.Remove(helper.Url2local(helper.SetSuffix(fpath, "_large.jpg")))
						os.Remove(helper.Url2local(helper.SetSuffix(fpath, "_medium.jpg")))
						os.Remove(helper.Url2local(helper.SetSuffix(fpath, "_small.jpg")))

					}
				}

			}
		}

	}

}
Пример #5
0
func main() {

	runtime.GOMAXPROCS(1)
	//遍历图集
	if mz, er := model.GetImagesByCtype(1); er == nil && len(*mz) > 0 {
		for k, v := range *mz {

			if thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, e := helper.MakeThumbnails(helper.Local2url(v.Location)); e == nil {
				fmt.Println("#", k, ":", thumbnails, thumbnailslarge, thumbnailsmedium, thumbnailssmall, e)
			} else {
				fmt.Println("@@@@@@@@@@@@@@@处理缩略图出错@@@@@@@@@@@@@@@@", er)
			}
		}
	}
	//覆写缩略图

}