package persistence import ( "database/sql" "offline_twitter/scraper" ) /** * Get the list of images for a tweet */ func (p Profile) GetImagesForTweet(t scraper.Tweet) (imgs []scraper.Image, err error) { stmt, err := p.DB.Prepare("select filename, is_downloaded from images where tweet_id=?") if err != nil { return } defer stmt.Close() rows, err := stmt.Query(t.ID) if err != nil { return } var img scraper.Image for rows.Next() { err = rows.Scan(&img.Filename, &img.IsDownloaded) if err != nil { return } img.TweetID = t.ID imgs = append(imgs, img) } return } /** * Get the list of videos for a tweet */ func (p Profile) GetVideosForTweet(t scraper.Tweet) (vids []scraper.Video, err error) { stmt, err := p.DB.Prepare("select filename, is_downloaded from videos where tweet_id=?") if err != nil { return } defer stmt.Close() rows, err := stmt.Query(t.ID) if err != nil { return } var vid scraper.Video for rows.Next() { err = rows.Scan(&vid.Filename, &vid.IsDownloaded) if err != nil { return } vid.TweetID = t.ID vids = append(vids, vid) } return }