@@ -426,4 +426,116 @@ func (d *Streamtape) ArchiveDecompress(ctx context.Context, srcObj, dstDir model
426426 return nil , errs .NotImplement
427427}
428428
429+ func (d * Streamtape ) Other (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
430+ switch strings .ToLower (args .Method ) {
431+ case "remotedl_status" :
432+ return d .remoteDlStatus (ctx , args )
433+ case "remotedl_remove" :
434+ return d .remoteDlRemove (ctx , args )
435+ case "file_info" :
436+ return d .fileInfo (ctx , args )
437+ case "thumbnail" :
438+ return d .thumbnail (ctx , args )
439+ case "conversion_status" :
440+ return d .conversionStatus (ctx , args )
441+ default :
442+ return nil , errs .NotSupport
443+ }
444+ }
445+
446+ func (d * Streamtape ) remoteDlStatus (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
447+ uploadID := remoteUploadIDFromObjID (args .Obj .GetID ())
448+ if uploadID == "" {
449+ // Try to get from data
450+ if data , ok := args .Data .(map [string ]interface {}); ok {
451+ if id , ok := data ["id" ].(string ); ok {
452+ uploadID = id
453+ }
454+ }
455+ }
456+ if uploadID == "" {
457+ return nil , fmt .Errorf ("remote upload ID required" )
458+ }
459+
460+ var result remoteDlStatusResult
461+ if err := d .callAPI (ctx , "/remotedl/status" , map [string ]string {"id" : uploadID }, & result ); err != nil {
462+ return nil , err
463+ }
464+ return result , nil
465+ }
466+
467+ func (d * Streamtape ) remoteDlRemove (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
468+ uploadID := remoteUploadIDFromObjID (args .Obj .GetID ())
469+ if uploadID == "" {
470+ // Try to get from data
471+ if data , ok := args .Data .(map [string ]interface {}); ok {
472+ if id , ok := data ["id" ].(string ); ok {
473+ uploadID = id
474+ }
475+ }
476+ }
477+ if uploadID == "" {
478+ return nil , fmt .Errorf ("remote upload ID required" )
479+ }
480+
481+ if err := d .callAPI (ctx , "/remotedl/remove" , map [string ]string {"id" : uploadID }, nil ); err != nil {
482+ return nil , err
483+ }
484+ return true , nil
485+ }
486+
487+ func (d * Streamtape ) fileInfo (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
488+ var fileIDs string
489+ if data , ok := args .Data .(map [string ]interface {}); ok {
490+ if ids , ok := data ["file_ids" ].(string ); ok {
491+ fileIDs = ids
492+ }
493+ }
494+ if fileIDs == "" {
495+ fileIDs = fileIDFromObjID (args .Obj .GetID ())
496+ }
497+ if fileIDs == "" {
498+ return nil , fmt .Errorf ("file IDs required" )
499+ }
500+
501+ var result fileInfoResult
502+ if err := d .callAPI (ctx , "/file/info" , map [string ]string {"file" : fileIDs }, & result ); err != nil {
503+ return nil , err
504+ }
505+ return result , nil
506+ }
507+
508+ func (d * Streamtape ) thumbnail (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
509+ fileID := fileIDFromObjID (args .Obj .GetID ())
510+ if fileID == "" {
511+ return nil , fmt .Errorf ("file ID required" )
512+ }
513+
514+ var result string
515+ if err := d .callAPI (ctx , "/file/getsplash" , map [string ]string {"file" : fileID }, & result ); err != nil {
516+ return nil , err
517+ }
518+ return result , nil
519+ }
520+
521+ func (d * Streamtape ) conversionStatus (ctx context.Context , args model.OtherArgs ) (interface {}, error ) {
522+ isFailed := false
523+ if data , ok := args .Data .(map [string ]interface {}); ok {
524+ if t , ok := data ["type" ].(string ); ok && t == "failed" {
525+ isFailed = true
526+ }
527+ }
528+
529+ endpoint := "/file/runningconverts"
530+ if isFailed {
531+ endpoint = "/file/failedconverts"
532+ }
533+
534+ var result conversionResult
535+ if err := d .callAPI (ctx , endpoint , nil , & result ); err != nil {
536+ return nil , err
537+ }
538+ return result , nil
539+ }
540+
429541var _ driver.Driver = (* Streamtape )(nil )
0 commit comments