refactor: enhance video processing logic to include additional checks and logging for better debugging
This commit is contained in:
parent
24b14fb3c1
commit
1c4471a327
2 changed files with 21 additions and 1 deletions
|
|
@ -166,6 +166,7 @@ func (m *MiogestHandler) ParseAnnunci(codFilter string, imgPool *[]typesdefs.Med
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// process only new or updated videos
|
// process only new or updated videos
|
||||||
video_codes_to_process, err = CodiciToProcessVideos(&annunci)
|
video_codes_to_process, err = CodiciToProcessVideos(&annunci)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,10 @@ func CodiciToProcessVideos(annunci *typesdefs.AnnunciXML) ([]string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to list bucket: %w", err)
|
return nil, fmt.Errorf("failed to list bucket: %w", err)
|
||||||
}
|
}
|
||||||
|
fmt.Println("Current bucket state items:", len(currentBucketState))
|
||||||
|
for _, item := range currentBucketState {
|
||||||
|
fmt.Println(" - ", item.OriginalName, " (ID:", item.ID+")")
|
||||||
|
}
|
||||||
//make a list of bucket ids
|
//make a list of bucket ids
|
||||||
bucketIdsMap := make(map[string]bool)
|
bucketIdsMap := make(map[string]bool)
|
||||||
for _, item := range currentBucketState {
|
for _, item := range currentBucketState {
|
||||||
|
|
@ -317,6 +321,10 @@ func CodiciToProcessVideos(annunci *typesdefs.AnnunciXML) ([]string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fmt.Println("DB videos items:", len(db_videos))
|
||||||
|
for _, item := range db_videos {
|
||||||
|
fmt.Println(" - ", item.Video, " (Codice:", item.Codice+")")
|
||||||
|
}
|
||||||
|
|
||||||
dbVideosMap := make(map[string][]videRef) // Convert slice to map for faster lookup
|
dbVideosMap := make(map[string][]videRef) // Convert slice to map for faster lookup
|
||||||
for _, ref := range db_videos {
|
for _, ref := range db_videos {
|
||||||
|
|
@ -330,7 +338,18 @@ func CodiciToProcessVideos(annunci *typesdefs.AnnunciXML) ([]string, error) {
|
||||||
var codiciToProcess []string
|
var codiciToProcess []string
|
||||||
for _, annuncio := range annunci.Annuncio {
|
for _, annuncio := range annunci.Annuncio {
|
||||||
|
|
||||||
if annuncio.Codice != nil && annuncio.AMMedias != nil {
|
if annuncio.Codice != nil && annuncio.AMMedias != nil && len(*annuncio.AMMedias) > 0 {
|
||||||
|
mediaUrls := []string{}
|
||||||
|
for _, media := range *annuncio.AMMedias {
|
||||||
|
if media.AMVideo != nil && media.AMVideo.Url != nil {
|
||||||
|
if strings.Contains(*media.AMVideo.Url, "video.miogest") {
|
||||||
|
mediaUrls = append(mediaUrls, *media.AMVideo.Url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(mediaUrls) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
refVideos, existsInDb := dbVideosMap[*annuncio.Codice]
|
refVideos, existsInDb := dbVideosMap[*annuncio.Codice]
|
||||||
if !existsInDb {
|
if !existsInDb {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue