@@ -13,6 +13,8 @@ import (
1313 "github.com/Wraient/octopus/internal"
1414)
1515
16+ const appVersion = "v0.0.2"
17+
1618func main () {
1719 var user internal.User
1820 var show internal.TVShow
@@ -36,6 +38,7 @@ func main() {
3638 logFile := filepath .Join (os .ExpandEnv (userIceConfig .StoragePath ), "debug.log" )
3739
3840 // Flags
41+ showVersion := flag .Bool ("v" , false , "Show version and exit" )
3942 flag .StringVar (& userIceConfig .Player , "player" , userIceConfig .Player , "Player to use (mpv)" )
4043 flag .StringVar (& userIceConfig .StoragePath , "storage-path" , userIceConfig .StoragePath , "Path to storage" )
4144 flag .IntVar (& userIceConfig .PercentageToMarkComplete , "percentage-to-mark-complete" , userIceConfig .PercentageToMarkComplete , "Percentage to mark complete" )
@@ -48,6 +51,11 @@ func main() {
4851 showImages := flag .Bool ("show-images" , false , "Show images in rofi (if available)" )
4952 flag .Parse ()
5053
54+ if * showVersion {
55+ fmt .Println (appVersion )
56+ return
57+ }
58+
5159 if * preferredQuality != "" {
5260 userIceConfig .PreferredQuality = * preferredQuality
5361 }
@@ -57,7 +65,9 @@ func main() {
5765 if * noRofi || runtime .GOOS == "windows" {
5866 userIceConfig .RofiSelection = false
5967 }
60- if * showImages { userIceConfig .ShowImages = true }
68+ if * showImages {
69+ userIceConfig .ShowImages = true
70+ }
6171
6272 // Save config if modified via flags
6373 internal .SetGlobalConfig (& userIceConfig )
@@ -88,16 +98,22 @@ func main() {
8898 if s .EpisodeNum > 0 && s .Season > 0 {
8999 label = fmt .Sprintf ("%s S%02dE%02d" , friendly , s .Season , s .EpisodeNum )
90100 }
91- if s .PlaybackTime > 0 { label += " (resume)" }
101+ if s .PlaybackTime > 0 {
102+ label += " (resume)"
103+ }
92104 // embed icon if config allows and image stored
93105 if userIceConfig .ShowImages && userIceConfig .RofiSelection && s .Image != "" {
94106 imgLabel := internal .BuildRofiOptionLabel (label , s .Image )
95- if strings .Contains (imgLabel , "\x00 icon\x1f " ) { imageUsedCW = true }
107+ if strings .Contains (imgLabel , "\x00 icon\x1f " ) {
108+ imageUsedCW = true
109+ }
96110 label = imgLabel
97111 }
98112 showOptions [s .ID ] = label
99113 }
100- if imageUsedCW { internal .RofiSetNextUsePreview (true ) }
114+ if imageUsedCW {
115+ internal .RofiSetNextUsePreview (true )
116+ }
101117 picked , err := internal .DynamicSelect (showOptions )
102118 if err != nil || picked .Key == "-1" { // user canceled; do not fall through to search
103119 return
@@ -143,19 +159,28 @@ func main() {
143159 label := r .Title
144160 if userIceConfig .ShowImages && userIceConfig .RofiSelection { // attempt image aware label
145161 imgLabel := internal .BuildRofiOptionLabel (r .Title , r .Image )
146- if strings .Contains (imgLabel , "\x00 icon\x1f " ) { imageUsed = true }
162+ if strings .Contains (imgLabel , "\x00 icon\x1f " ) {
163+ imageUsed = true
164+ }
147165 label = imgLabel
148166 }
149167 opt [r .URL ] = label
150168 }
151- if imageUsed { internal .RofiSetNextUsePreview (true ) }
169+ if imageUsed {
170+ internal .RofiSetNextUsePreview (true )
171+ }
152172 picked , err := internal .DynamicSelect (opt )
153173 if err != nil || picked .Key == "-1" {
154174 return
155175 }
156176 // capture image url from search result match if available
157177 imgURL := ""
158- for _ , r := range results { if r .URL == picked .Key { imgURL = r .Image ; break } }
178+ for _ , r := range results {
179+ if r .URL == picked .Key {
180+ imgURL = r .Image
181+ break
182+ }
183+ }
159184 show = internal.TVShow {ID : picked .Key , EpisodeID : "" , PlaybackTime : 0 , Image : imgURL }
160185 }
161186
0 commit comments