Find installed browser for Docker (#17)
* trying a different method to have rod find to brower on disk for docker * updated rod to find the browser on disk. This is for docker support
This commit is contained in:
parent
9d662936d5
commit
66c74802d9
@ -7,7 +7,10 @@ RUN go install github.com/pressly/goose/v3/cmd/goose@latest
|
||||
|
||||
FROM alpine:latest as app
|
||||
|
||||
RUN apk --no-cache add bash libc6-compat chromium
|
||||
RUN apk --no-cache add bash
|
||||
RUN apk --no-cache add libc6-compat
|
||||
RUN apk --no-cache add chromium
|
||||
|
||||
RUN mkdir /app && mkdir /app/migrations
|
||||
COPY --from=build /app/collector /app
|
||||
COPY --from=build /go/bin/goose /app
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/go-rod/rod"
|
||||
"github.com/go-rod/rod/lib/launcher"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/jtom38/newsbot/collector/database"
|
||||
@ -113,7 +114,11 @@ func (fc *FFXIVClient) GetParser() (*goquery.Document, error) {
|
||||
}
|
||||
|
||||
func (fc *FFXIVClient) GetBrowser() (*rod.Browser) {
|
||||
browser := rod.New().MustConnect()
|
||||
var browser *rod.Browser
|
||||
if path, exists := launcher.LookPath(); exists {
|
||||
u := launcher.New().Bin(path).MustLaunch()
|
||||
browser = rod.New().ControlURL(u).MustConnect()
|
||||
}
|
||||
return browser
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-rod/rod"
|
||||
"github.com/go-rod/rod/lib/launcher"
|
||||
"github.com/jtom38/newsbot/collector/database"
|
||||
"github.com/jtom38/newsbot/collector/domain/model"
|
||||
"github.com/jtom38/newsbot/collector/services/config"
|
||||
@ -48,7 +49,11 @@ func NewRedditClient(Record database.Source) *RedditClient {
|
||||
|
||||
|
||||
func (rc *RedditClient) GetBrowser() *rod.Browser {
|
||||
browser := rod.New().MustConnect()
|
||||
var browser *rod.Browser
|
||||
if path, exists := launcher.LookPath(); exists {
|
||||
u := launcher.New().Bin(path).MustLaunch()
|
||||
browser = rod.New().ControlURL(u).MustConnect()
|
||||
}
|
||||
return browser
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/go-rod/rod"
|
||||
"github.com/go-rod/rod/lib/launcher"
|
||||
"github.com/mmcdole/gofeed"
|
||||
|
||||
"github.com/jtom38/newsbot/collector/database"
|
||||
@ -32,7 +33,7 @@ type YoutubeClient struct {
|
||||
|
||||
var (
|
||||
// This is a local slice to store what URI's have been seen to remove extra calls to the DB
|
||||
YoutubeUriCache []*string
|
||||
YoutubeUriCache []*string
|
||||
ErrYoutubeChannelIdMissing = errors.New("unable to find the channelId on the requested page")
|
||||
)
|
||||
|
||||
@ -40,7 +41,7 @@ const YOUTUBE_FEED_URL string = "https://www.youtube.com/feeds/videos.xml?channe
|
||||
|
||||
func NewYoutubeClient(Record database.Source) YoutubeClient {
|
||||
yc := YoutubeClient{
|
||||
record: Record,
|
||||
record: Record,
|
||||
cacheGroup: "youtube",
|
||||
}
|
||||
/*
|
||||
@ -109,7 +110,12 @@ func (yc *YoutubeClient) GetContent() ([]database.Article, error) {
|
||||
}
|
||||
|
||||
func (yc *YoutubeClient) GetBrowser() *rod.Browser {
|
||||
browser := rod.New().MustConnect()
|
||||
//browser := rod.New().MustConnect()
|
||||
var browser *rod.Browser
|
||||
if path, exists := launcher.LookPath(); exists {
|
||||
u := launcher.New().Bin(path).MustLaunch()
|
||||
browser = rod.New().ControlURL(u).MustConnect()
|
||||
}
|
||||
return browser
|
||||
}
|
||||
|
||||
@ -156,7 +162,8 @@ func (yc *YoutubeClient) GetChannelId(doc *goquery.Document) (string, error) {
|
||||
func (yc *YoutubeClient) GetAvatarUri() (string, error) {
|
||||
var AvatarUri string
|
||||
|
||||
browser := rod.New().MustConnect()
|
||||
//browser := rod.New().MustConnect()
|
||||
browser := yc.GetBrowser()
|
||||
page := browser.MustPage(yc.record.Url)
|
||||
|
||||
res := page.MustElement("#channel-header-container > yt-img-shadow:nth-child(1) > img:nth-child(1)").MustAttribute("src")
|
||||
|
Loading…
Reference in New Issue
Block a user