diff --git a/backend/database/.transform.yaml b/backend/database/.transform.yaml index a7e5ef8..5c40142 100755 --- a/backend/database/.transform.yaml +++ b/backend/database/.transform.yaml @@ -5,4 +5,3 @@ types: media_resources: # table name type: backend/pkg/pg.MediaType - source: backend/pkg/pg.MediaSource diff --git a/backend/database/migrations/20241128075611_init.sql b/backend/database/migrations/20241128075611_init.sql index 0838966..3f8dc87 100644 --- a/backend/database/migrations/20241128075611_init.sql +++ b/backend/database/migrations/20241128075611_init.sql @@ -87,7 +87,7 @@ CREATE TABLE id SERIAL8 PRIMARY KEY, media_id INT8 NOT NULL, type VARCHAR(128) NOT NULL, - source jsonb default '{}'::jsonb, + source text NOT NULL default '', size INT8 NOT NULL, publish BOOL NOT NULL, created_at timestamp NOT NULL default now(), diff --git a/backend/database/models/qvyun/public/model/media_resources.go b/backend/database/models/qvyun/public/model/media_resources.go index 39360a3..e7ffa76 100644 --- a/backend/database/models/qvyun/public/model/media_resources.go +++ b/backend/database/models/qvyun/public/model/media_resources.go @@ -16,7 +16,7 @@ type MediaResources struct { ID int64 `sql:"primary_key" json:"id"` MediaID int64 `json:"media_id"` Type pg.MediaType `json:"type"` - Source *string `json:"source"` + Source string `json:"source"` Size int64 `json:"size"` Publish bool `json:"publish"` CreatedAt time.Time `json:"created_at"` diff --git a/backend/modules/medias/service_test.go b/backend/modules/medias/service_test.go index 846da15..7ecea43 100644 --- a/backend/modules/medias/service_test.go +++ b/backend/modules/medias/service_test.go @@ -118,42 +118,36 @@ func TestService_List(t *testing.T) { { MediaID: 1, Type: pg.MediaTypeVideo, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, { MediaID: 1, Type: pg.MediaTypeAudio, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, { MediaID: 2, Type: pg.MediaTypeVideo, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, { MediaID: 2, Type: pg.MediaTypeAudio, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, { MediaID: 3, Type: pg.MediaTypeVideo, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, { MediaID: 3, Type: pg.MediaTypeAudio, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, @@ -206,10 +200,6 @@ func TestService_List1(t *testing.T) { t.Log(stmt.DebugSql()) - type list struct { - Media model.Medias `alias:"ListItem.*"` - } - var dest []ListItem err = stmt.QueryContext(context.TODO(), db, &dest) So(err, ShouldBeNil) @@ -234,14 +224,12 @@ func TestService_DecorateListResources(t *testing.T) { { MediaID: 1, Type: pg.MediaTypeVideo, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, { MediaID: 2, Type: pg.MediaTypeAudio, - Source: lo.ToPtr("http://www.baidu.com"), Size: 100, Publish: true, }, diff --git a/backend/modules/tasks/discover_medias_test.go b/backend/modules/tasks/discover_medias_test.go index 166f050..eee982c 100644 --- a/backend/modules/tasks/discover_medias_test.go +++ b/backend/modules/tasks/discover_medias_test.go @@ -79,6 +79,8 @@ func (t *DiscoverMediasTestSuite) Test_parseM3u8File() { playlist, err := t.Svc.parseM3u8File(file) So(err, ShouldBeNil) - t.T().Logf("ListType: %+v", playlist) + t.T().Logf("Live: %+v", playlist.IsLive()) + t.T().Logf("IsMaster: %+v", playlist.IsMaster()) + t.T().Logf("Size: %+v", playlist.Segments()) }) }