@saooti/octopus-sdk 41.0.0 → 41.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "41.0.0",
3
+ "version": "41.0.1",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -2,17 +2,19 @@ import classicApi from "../../../api/classicApi";
2
2
  import { MediaRadio, MetadataRadio, NextAdvertising } from '@/stores/class/general/player';
3
3
  import { Podcast } from '@/stores/class/general/podcast';
4
4
  import dayjs from 'dayjs';
5
- import radioHelper from "../../../helper/radio/radioHelper";
6
5
  import {onBeforeUnmount, Ref, ref} from 'vue';
6
+ import { useI18n } from "vue-i18n";
7
7
  export const useFetchRadio = ()=>{
8
8
 
9
9
  const radioInterval : Ref<ReturnType<typeof setTimeout> | undefined> = ref(undefined);
10
+
11
+ const {t} = useI18n();
10
12
 
11
13
  async function fetchRadioMetadata(
12
14
  canalId: number,
13
15
  previousTitle: string,
14
16
  callbackMetadata: (
15
- metadata: MediaRadio,
17
+ metadata: MediaRadio|undefined,
16
18
  podcast: Podcast | undefined,
17
19
  history: Array<MediaRadio>
18
20
  ) => void,
@@ -33,15 +35,19 @@ export const useFetchRadio = ()=>{
33
35
  callbackAdvertising(metadata.nextAdvertising);
34
36
  }
35
37
  const arrayMetadata = metadata.previously;
36
- arrayMetadata.unshift(metadata.currently);
37
- for (let index = 0, len = arrayMetadata.length; index < len; index++) {
38
- if (
39
- dayjs().valueOf() - 18000 >
40
- dayjs(arrayMetadata[index].startDate).valueOf()
41
- ) {
42
- await useCallbackIfNewMetadata(previousTitle, arrayMetadata, index, len,callbackMetadata);
43
- return;
38
+ if(null!==metadata.currently){
39
+ arrayMetadata.unshift(metadata.currently);
40
+ for (let index = 0, len = arrayMetadata.length; index < len; index++) {
41
+ if (
42
+ dayjs().valueOf() - 18000 >
43
+ dayjs(arrayMetadata[index].startDate).valueOf()
44
+ ) {
45
+ await useCallbackIfNewMetadata(previousTitle, arrayMetadata, index, len,callbackMetadata);
46
+ return;
47
+ }
44
48
  }
49
+ }else{
50
+ callbackMetadata(undefined, undefined, arrayMetadata);
45
51
  }
46
52
  }
47
53
  async function useCallbackIfNewMetadata(previousTitle: string, arrayMetadata: Array<MediaRadio>, index:number, len: number, callbackMetadata: (
@@ -63,11 +69,22 @@ export const useFetchRadio = ()=>{
63
69
  }
64
70
  }
65
71
  }
66
- function displayTitle(metadata: MediaRadio): string {
67
- return radioHelper.displayTitle(metadata);
72
+ function displayTitle(metadata: MediaRadio|undefined): string {
73
+ if(!metadata){
74
+ return t("Silent stream");
75
+ }
76
+ let title = "";
77
+ if (metadata?.title) {
78
+ title += metadata.title;
79
+ }
80
+ if (metadata?.artist) {
81
+ title += " - " + metadata.artist;
82
+ }
83
+ return title;
68
84
  }
69
85
 
70
86
 
87
+
71
88
  onBeforeUnmount(() => {
72
89
  clearInterval(radioInterval.value as unknown as number);
73
90
  })
@@ -72,10 +72,7 @@ const currentlyPlayingString = computed(() => {
72
72
  if (playingRadio.value && playerStore.playerRadio) {
73
73
  return displayTitle(playerStore.playerRadio.metadata);
74
74
  }
75
- if (currentMetadata.value) {
76
- return displayTitle(currentMetadata.value);
77
- }
78
- return "";
75
+ return displayTitle(currentMetadata.value);
79
76
  });
80
77
 
81
78
  onMounted(()=>{
@@ -102,7 +99,7 @@ async function fetchCurrentlyPlaying(): Promise<void> {
102
99
  updateMetadata,
103
100
  );
104
101
  }
105
- function updateMetadata(metadata: MediaRadio, podcast?: Podcast): void {
102
+ function updateMetadata(metadata: MediaRadio|undefined, podcast?: Podcast): void {
106
103
  currentMetadata.value = metadata;
107
104
  currentPodcast.value = podcast;
108
105
  }
@@ -89,7 +89,7 @@ onUnmounted(()=>{
89
89
  async function fetchCurrentlyPlaying(): Promise<void> {
90
90
  fetchRadioMetadata(
91
91
  playerStore.playerRadio?.canalId ?? 0,
92
- playerStore.playerRadio?.metadata.title ?? "",
92
+ playerStore.playerRadio?.metadata?.title ?? "",
93
93
  updateMetadata,
94
94
  updateAdvertising,
95
95
  );
@@ -98,11 +98,11 @@ function updateAdvertising(nextAdvertising: NextAdvertising): void {
98
98
  playerStore.playerRadioUpdateNextAdvertising(nextAdvertising);
99
99
  }
100
100
  function updateMetadata(
101
- metadata: MediaRadio,
101
+ metadata: MediaRadio|undefined,
102
102
  podcast: Podcast | undefined,
103
103
  history: Array<MediaRadio>,
104
104
  ): void {
105
- playerStore.playerMetadata(metadata, history);
105
+ playerStore.playerMetadata(metadata, history); //TODO
106
106
  playerStore.playerRadioPodcast(podcast);
107
107
  }
108
108
  </script>
@@ -40,10 +40,10 @@ import ChevronLeftIcon from "vue-material-design-icons/ChevronLeft.vue";
40
40
  import ChevronRightIcon from "vue-material-design-icons/ChevronRight.vue";
41
41
  import { usePlayerStore } from "../../../../stores/PlayerStore";
42
42
  import dayjs from "dayjs";
43
- import radioHelper from "../../../../helper/radio/radioHelper";
44
43
  import { computed, nextTick, onMounted, onUnmounted, ref, useTemplateRef, watch } from "vue";
45
44
  import { MediaRadio } from "@/stores/class/general/player";
46
45
  import { useI18n } from "vue-i18n";
46
+ import { useFetchRadio } from "@/components/composable/radio/usefetchRadioData";
47
47
 
48
48
 
49
49
  //Data
@@ -54,6 +54,7 @@ const historyListContainerRef = useTemplateRef('historyListContainer');
54
54
  //Composables
55
55
  const { t } = useI18n();
56
56
  const playerStore = usePlayerStore();
57
+ const {displayTitle} = useFetchRadio();
57
58
 
58
59
 
59
60
  //Computed
@@ -119,7 +120,7 @@ function displayPreviousItem(item: MediaRadio): string {
119
120
  if (item.podcastId) {
120
121
  return item.title;
121
122
  }
122
- return radioHelper.displayTitle(item);
123
+ return displayTitle(item);
123
124
  }
124
125
  </script>
125
126
  <style lang="scss">
package/src/locale/de.ts CHANGED
@@ -414,4 +414,5 @@ export default {
414
414
  "Code copied!":"Code kopiert!",
415
415
  "Copied!":"Kopiert!",
416
416
  "Color of the QR Code": "Farbe des QR-Codes",
417
+ "Silent stream":"Stiller Fluss",
417
418
  }
package/src/locale/en.ts CHANGED
@@ -417,4 +417,5 @@ export default {
417
417
  "Code copied!":"Code copied!",
418
418
  "Copied!":"Copied!",
419
419
  "Color of the QR Code": "Color of the QR Code",
420
+ "Silent stream":"Silent stream",
420
421
  };
package/src/locale/es.ts CHANGED
@@ -415,4 +415,5 @@ export default {
415
415
  "Code copied!":"¡Código copiado!",
416
416
  "Copied!":"¡Copiado!",
417
417
  "Color of the QR Code": "Color del código QR",
418
+ "Silent stream":"Flujo silencioso",
418
419
  }
package/src/locale/fr.ts CHANGED
@@ -424,4 +424,5 @@ export default {
424
424
  "Code copied!":"Code copié !",
425
425
  "Copied!":"Copié !",
426
426
  "Color of the QR Code": "Couleur du Qr Code",
427
+ "Silent stream":"Flux silencieux",
427
428
  };
package/src/locale/it.ts CHANGED
@@ -411,4 +411,5 @@ export default{
411
411
  "Code copied!":"Codice copiato!",
412
412
  "Copied!":"Copiato!",
413
413
  "Color of the QR Code": "Colore del codice QR",
414
+ "Silent stream":"Flusso silenzioso",
414
415
  };
package/src/locale/sl.ts CHANGED
@@ -406,4 +406,5 @@ export default {
406
406
  "Code copied!":"Koda kopirana!",
407
407
  "Copied!":"Kopirano!",
408
408
  "Color of the QR Code": "Barva kode QR",
409
+ "Silent stream":"Tihi tok",
409
410
  }
@@ -210,7 +210,7 @@ export const usePlayerStore = defineStore("PlayerStore", {
210
210
  playerUpdateSeekTime(seekTime: number) {
211
211
  this.playerSeekTime = seekTime;
212
212
  },
213
- playerMetadata(metadata: MediaRadio, history: Array<MediaRadio>) {
213
+ playerMetadata(metadata: MediaRadio|undefined, history: Array<MediaRadio>) {
214
214
  if (!this.playerRadio) {
215
215
  return;
216
216
  }
@@ -4,7 +4,7 @@ import { Podcast } from "./podcast";
4
4
  export interface Radio {
5
5
  canalId: number;
6
6
  url: string;
7
- metadata: MediaRadio;
7
+ metadata?: MediaRadio;
8
8
  history: Array<MediaRadio>;
9
9
  nextAdvertising: NextAdvertising;
10
10
  isInit: boolean;
@@ -30,7 +30,7 @@ export interface NextAdvertising {
30
30
 
31
31
  export interface MetadataRadio {
32
32
  channelId: number;
33
- currently: MediaRadio;
33
+ currently: MediaRadio|null;
34
34
  previously: Array<MediaRadio>;
35
35
  nextAdvertising: NextAdvertising;
36
36
  }
@@ -1,15 +0,0 @@
1
- import { MediaRadio } from "@/stores/class/general/player";
2
-
3
- export default {
4
- displayTitle(metadata: MediaRadio): string {
5
- let title = "";
6
- if (metadata.title) {
7
- title += metadata.title;
8
- }
9
- if (metadata.artist) {
10
- title += " - " + metadata.artist;
11
- }
12
- return title;
13
- }
14
- };
15
-