@@ -15,7 +15,7 @@ import (
1515func main () {
1616 // Parse command line flags
1717 configPath := flag .String ("config" , "config/config.toml" , "Path to configuration file" )
18- exportType := flag .String ("export" , "watched" , "Type of export (watched, collection, shows, all)" )
18+ exportType := flag .String ("export" , "watched" , "Type of export (watched, collection, shows, ratings, watchlist, all)" )
1919 flag .Parse ()
2020
2121 // Initialize logger
@@ -65,13 +65,19 @@ func main() {
6565 exportCollection (traktClient , letterboxdExporter , log )
6666 case "shows" :
6767 exportShows (traktClient , letterboxdExporter , log )
68+ case "ratings" :
69+ exportRatings (traktClient , letterboxdExporter , log )
70+ case "watchlist" :
71+ exportWatchlist (traktClient , letterboxdExporter , log )
6872 case "all" :
6973 exportWatchedMovies (traktClient , letterboxdExporter , log )
7074 exportCollection (traktClient , letterboxdExporter , log )
7175 exportShows (traktClient , letterboxdExporter , log )
76+ exportRatings (traktClient , letterboxdExporter , log )
77+ exportWatchlist (traktClient , letterboxdExporter , log )
7278 default :
7379 log .Error ("errors.invalid_export_type" , map [string ]interface {}{"type" : * exportType })
74- fmt .Printf ("Invalid export type: %s. Valid types are 'watched', 'collection', 'shows', or 'all'\n " , * exportType )
80+ fmt .Printf ("Invalid export type: %s. Valid types are 'watched', 'collection', 'shows', 'ratings', 'watchlist', or 'all'\n " , * exportType )
7581 os .Exit (1 )
7682 }
7783
@@ -144,4 +150,42 @@ func exportShows(client *api.Client, exporter *export.LetterboxdExporter, log lo
144150 log .Error ("export.export_failed" , map [string ]interface {}{"error" : err .Error ()})
145151 os .Exit (1 )
146152 }
153+ }
154+
155+ func exportRatings (client * api.Client , exporter * export.LetterboxdExporter , log logger.Logger ) {
156+ // Get ratings
157+ log .Info ("export.retrieving_ratings" , nil )
158+ ratings , err := client .GetRatings ()
159+ if err != nil {
160+ log .Error ("errors.api_request_failed" , map [string ]interface {}{"error" : err .Error ()})
161+ os .Exit (1 )
162+ }
163+
164+ log .Info ("export.ratings_retrieved" , map [string ]interface {}{"count" : len (ratings )})
165+
166+ // Export ratings
167+ log .Info ("export.exporting_ratings" , nil )
168+ if err := exporter .ExportRatings (ratings ); err != nil {
169+ log .Error ("export.export_failed" , map [string ]interface {}{"error" : err .Error ()})
170+ os .Exit (1 )
171+ }
172+ }
173+
174+ func exportWatchlist (client * api.Client , exporter * export.LetterboxdExporter , log logger.Logger ) {
175+ // Get watchlist
176+ log .Info ("export.retrieving_watchlist" , nil )
177+ watchlist , err := client .GetWatchlist ()
178+ if err != nil {
179+ log .Error ("errors.api_request_failed" , map [string ]interface {}{"error" : err .Error ()})
180+ os .Exit (1 )
181+ }
182+
183+ log .Info ("export.watchlist_retrieved" , map [string ]interface {}{"count" : len (watchlist )})
184+
185+ // Export watchlist
186+ log .Info ("export.exporting_watchlist" , nil )
187+ if err := exporter .ExportWatchlist (watchlist ); err != nil {
188+ log .Error ("export.export_failed" , map [string ]interface {}{"error" : err .Error ()})
189+ os .Exit (1 )
190+ }
147191}
0 commit comments