Change Images for Debug Mode

This commit is contained in:
2020-01-16 11:59:44 +01:00
parent dcce29ab78
commit 79abcb72fb
2 changed files with 12 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import (
"regexp"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/page"
"github.com/robfig/cron/v3"
)
@@ -30,6 +31,9 @@ const (
fbPageURL string = "https://www.facebook.com/herowarsgame/"
// fbGameURL for search on expaned urls
fbGameURL string = "apps.facebook.com/mobaheroes"
imageQuality int64 = 85
imageFormat page.CaptureScreenshotFormat = page.CaptureScreenshotFormatJpeg
)
// Constants for title of the Postings

View File

@@ -25,11 +25,11 @@ func makeScreenShot(c context.Context, page string) {
if viper.GetBool("development_mode") {
// capture entire browser viewport, returning png with quality=90
if err := chromedp.Run(c, fullScreenshot(90, &buf, &content)); err != nil {
if err := chromedp.Run(c, fullScreenshot(imageQuality, &buf, &content)); err != nil {
//log.Fatal(err)
}
if err := ioutil.WriteFile("/opt/tmp/"+timeNow+"-"+page+"-fullScreenshot.png", buf, 0644); err != nil {
if err := ioutil.WriteFile("/opt/tmp/"+timeNow+"-"+page+"-fullScreenshot.jpeg", buf, 0644); err != nil {
//log.Fatal(err)
}
@@ -48,12 +48,12 @@ func makeScreenShotAndParsePost(c context.Context, page string) (*FBPostData, er
var content string
// capture entire browser viewport, returning png with quality=90
if err := chromedp.Run(c, fullScreenshot(90, &buf, &content)); err != nil {
if err := chromedp.Run(c, fullScreenshot(imageQuality, &buf, &content)); err != nil {
//log.Fatal(err)
}
if viper.GetBool("development_mode") {
if err := ioutil.WriteFile("/opt/tmp/"+timeNow+"-"+page+"-fullScreenshot.png", buf, 0644); err != nil {
if err := ioutil.WriteFile("/opt/tmp/"+timeNow+"-"+page+"-fullScreenshot.jpeg", buf, 0644); err != nil {
//log.Fatal(err)
}
@@ -74,11 +74,11 @@ func makeScreenShotOnly(c context.Context, page string) {
if viper.GetBool("development_mode") {
// capture entire browser viewport, returning png with quality=90
if err := chromedp.Run(c, fullScreenshotOnly(90, &buf)); err != nil {
if err := chromedp.Run(c, fullScreenshotOnly(imageQuality, &buf)); err != nil {
//log.Fatal(err)
}
if err := ioutil.WriteFile("/opt/tmp/"+timeNow+"-"+page+"-fullScreenshot.png", buf, 0644); err != nil {
if err := ioutil.WriteFile("/opt/tmp/"+timeNow+"-"+page+"-fullScreenshot.jpeg", buf, 0644); err != nil {
//log.Fatal(err)
}
}
@@ -115,6 +115,7 @@ func fullScreenshot(quality int64, res *[]byte, content *string) chromedp.Tasks
// capture screenshot
*res, err = page.CaptureScreenshot().
WithFormat(imageFormat).
WithQuality(quality).
WithClip(&page.Viewport{
X: contentSize.X,
@@ -162,6 +163,7 @@ func fullScreenshotOnly(quality int64, res *[]byte) chromedp.Tasks {
// capture screenshot
*res, err = page.CaptureScreenshot().
WithFormat(imageFormat).
WithQuality(quality).
WithClip(&page.Viewport{
X: contentSize.X,