mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-11-03 19:07:00 -05:00 
			
		
		
		
	移动播客搜索地区配置到媒体库配置
This commit is contained in:
		
							parent
							
								
									1be34564f2
								
							
						
					
					
						commit
						fea78898a5
					
				@ -49,6 +49,9 @@
 | 
				
			|||||||
        </ui-tooltip>
 | 
					        </ui-tooltip>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div v-if="isPodcastLibrary" class="py-3">
 | 
				
			||||||
 | 
					      <ui-dropdown :label="$strings.LabelPodcastSearchRegion" v-model="podcastSearchRegion" :items="$podcastSearchRegionOptions" small class="max-w-52" @input="formUpdated" />
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -69,7 +72,8 @@ export default {
 | 
				
			|||||||
      skipMatchingMediaWithAsin: false,
 | 
					      skipMatchingMediaWithAsin: false,
 | 
				
			||||||
      skipMatchingMediaWithIsbn: false,
 | 
					      skipMatchingMediaWithIsbn: false,
 | 
				
			||||||
      audiobooksOnly: false,
 | 
					      audiobooksOnly: false,
 | 
				
			||||||
      hideSingleBookSeries: false
 | 
					      hideSingleBookSeries: false,
 | 
				
			||||||
 | 
					      podcastSearchRegion: 'us'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  computed: {
 | 
					  computed: {
 | 
				
			||||||
@ -85,6 +89,9 @@ export default {
 | 
				
			|||||||
    isBookLibrary() {
 | 
					    isBookLibrary() {
 | 
				
			||||||
      return this.mediaType === 'book'
 | 
					      return this.mediaType === 'book'
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    isPodcastLibrary() {
 | 
				
			||||||
 | 
					      return this.mediaType === 'podcast'
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    providers() {
 | 
					    providers() {
 | 
				
			||||||
      if (this.mediaType === 'podcast') return this.$store.state.scanners.podcastProviders
 | 
					      if (this.mediaType === 'podcast') return this.$store.state.scanners.podcastProviders
 | 
				
			||||||
      return this.$store.state.scanners.providers
 | 
					      return this.$store.state.scanners.providers
 | 
				
			||||||
@ -99,7 +106,8 @@ export default {
 | 
				
			|||||||
          skipMatchingMediaWithAsin: !!this.skipMatchingMediaWithAsin,
 | 
					          skipMatchingMediaWithAsin: !!this.skipMatchingMediaWithAsin,
 | 
				
			||||||
          skipMatchingMediaWithIsbn: !!this.skipMatchingMediaWithIsbn,
 | 
					          skipMatchingMediaWithIsbn: !!this.skipMatchingMediaWithIsbn,
 | 
				
			||||||
          audiobooksOnly: !!this.audiobooksOnly,
 | 
					          audiobooksOnly: !!this.audiobooksOnly,
 | 
				
			||||||
          hideSingleBookSeries: !!this.hideSingleBookSeries
 | 
					          hideSingleBookSeries: !!this.hideSingleBookSeries,
 | 
				
			||||||
 | 
					          podcastSearchRegion: this.podcastSearchRegion
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -112,7 +120,8 @@ export default {
 | 
				
			|||||||
      this.skipMatchingMediaWithAsin = !!this.librarySettings.skipMatchingMediaWithAsin
 | 
					      this.skipMatchingMediaWithAsin = !!this.librarySettings.skipMatchingMediaWithAsin
 | 
				
			||||||
      this.skipMatchingMediaWithIsbn = !!this.librarySettings.skipMatchingMediaWithIsbn
 | 
					      this.skipMatchingMediaWithIsbn = !!this.librarySettings.skipMatchingMediaWithIsbn
 | 
				
			||||||
      this.audiobooksOnly = !!this.librarySettings.audiobooksOnly
 | 
					      this.audiobooksOnly = !!this.librarySettings.audiobooksOnly
 | 
				
			||||||
      this.hideSingleBookSeries = !!this.librarySettings.hideSingleBookSeries
 | 
					      this.hideSingleBookSeries = !!this.librarySettings.hideSingleBookSeries,
 | 
				
			||||||
 | 
					      this.podcastSearchRegion = this.librarySettings.podcastSearchRegion
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mounted() {
 | 
					  mounted() {
 | 
				
			||||||
 | 
				
			|||||||
@ -135,10 +135,6 @@
 | 
				
			|||||||
            <ui-dropdown :label="$strings.LabelLanguageDefaultServer" ref="langDropdown" v-model="newServerSettings.language" :items="$languageCodeOptions" small class="max-w-52" @input="updateServerLanguage" />
 | 
					            <ui-dropdown :label="$strings.LabelLanguageDefaultServer" ref="langDropdown" v-model="newServerSettings.language" :items="$languageCodeOptions" small class="max-w-52" @input="updateServerLanguage" />
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          <div class="py-2">
 | 
					 | 
				
			||||||
            <ui-dropdown :label="$strings.LabelPodcastSearchRegion" v-model="newServerSettings.podcastSearchRegion" :items="$podcastSearchRegionOptions" small class="max-w-52" @input="(val) => updateSettingsKey('podcastSearchRegion', val)" />
 | 
					 | 
				
			||||||
          </div>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          <!-- old experimental features -->
 | 
					          <!-- old experimental features -->
 | 
				
			||||||
          <!-- <div class="pt-4">
 | 
					          <!-- <div class="pt-4">
 | 
				
			||||||
            <h2 class="font-semibold">{{ $strings.HeaderSettingsExperimental }}</h2>
 | 
					            <h2 class="font-semibold">{{ $strings.HeaderSettingsExperimental }}</h2>
 | 
				
			||||||
 | 
				
			|||||||
@ -86,6 +86,9 @@ export default {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    streamLibraryItem() {
 | 
					    streamLibraryItem() {
 | 
				
			||||||
      return this.$store.state.streamLibraryItem
 | 
					      return this.$store.state.streamLibraryItem
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    librarySetting() {
 | 
				
			||||||
 | 
					      return this.$store.getters['libraries/getCurrentLibrarySettings']
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
@ -151,7 +154,7 @@ export default {
 | 
				
			|||||||
    async submitSearch(term) {
 | 
					    async submitSearch(term) {
 | 
				
			||||||
      this.processing = true
 | 
					      this.processing = true
 | 
				
			||||||
      this.termSearched = ''
 | 
					      this.termSearched = ''
 | 
				
			||||||
      let results = await this.$axios.$get(`/api/search/podcast?term=${encodeURIComponent(term)}`).catch((error) => {
 | 
					      let results = await this.$axios.$get(`/api/search/podcast?term=${encodeURIComponent(term)}&country=${encodeURIComponent(this.librarySetting?.podcastSearchRegion)}`).catch((error) => {
 | 
				
			||||||
        console.error('Search request failed', error)
 | 
					        console.error('Search request failed', error)
 | 
				
			||||||
        return []
 | 
					        return []
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
 | 
				
			|||||||
@ -43,12 +43,15 @@ class SearchController {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  async findPodcasts(req, res) {
 | 
					  async findPodcasts(req, res) {
 | 
				
			||||||
    const term = req.query.term
 | 
					    const term = req.query.term
 | 
				
			||||||
 | 
					    const country = req.query.country
 | 
				
			||||||
    if (!term) {
 | 
					    if (!term) {
 | 
				
			||||||
      Logger.error('[SearchController] Invalid request query param "term" is required')
 | 
					      Logger.error('[SearchController] Invalid request query param "term" is required')
 | 
				
			||||||
      return res.status(400).send('Invalid request query param "term" is required')
 | 
					      return res.status(400).send('Invalid request query param "term" is required')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const results = await PodcastFinder.search(term)
 | 
					    const results = await PodcastFinder.search(term, {
 | 
				
			||||||
 | 
					      country: country
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
    res.json(results)
 | 
					    res.json(results)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,7 @@ class LibrarySettings {
 | 
				
			|||||||
    this.audiobooksOnly = false
 | 
					    this.audiobooksOnly = false
 | 
				
			||||||
    this.hideSingleBookSeries = false // Do not show series that only have 1 book 
 | 
					    this.hideSingleBookSeries = false // Do not show series that only have 1 book 
 | 
				
			||||||
    this.metadataPrecedence = ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
 | 
					    this.metadataPrecedence = ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
 | 
				
			||||||
 | 
					    this.podcastSearchRegion = 'us'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settings) {
 | 
					    if (settings) {
 | 
				
			||||||
      this.construct(settings)
 | 
					      this.construct(settings)
 | 
				
			||||||
@ -30,6 +31,7 @@ class LibrarySettings {
 | 
				
			|||||||
      // Added in v2.4.5
 | 
					      // Added in v2.4.5
 | 
				
			||||||
      this.metadataPrecedence = ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
 | 
					      this.metadataPrecedence = ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    this.podcastSearchRegion = settings.podcastSearchRegion || 'us'
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  toJSON() {
 | 
					  toJSON() {
 | 
				
			||||||
@ -41,7 +43,8 @@ class LibrarySettings {
 | 
				
			|||||||
      autoScanCronExpression: this.autoScanCronExpression,
 | 
					      autoScanCronExpression: this.autoScanCronExpression,
 | 
				
			||||||
      audiobooksOnly: this.audiobooksOnly,
 | 
					      audiobooksOnly: this.audiobooksOnly,
 | 
				
			||||||
      hideSingleBookSeries: this.hideSingleBookSeries,
 | 
					      hideSingleBookSeries: this.hideSingleBookSeries,
 | 
				
			||||||
      metadataPrecedence: [...this.metadataPrecedence]
 | 
					      metadataPrecedence: [...this.metadataPrecedence],
 | 
				
			||||||
 | 
					      podcastSearchRegion: this.podcastSearchRegion
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -48,7 +48,6 @@ class ServerSettings {
 | 
				
			|||||||
    this.dateFormat = 'MM/dd/yyyy'
 | 
					    this.dateFormat = 'MM/dd/yyyy'
 | 
				
			||||||
    this.timeFormat = 'HH:mm'
 | 
					    this.timeFormat = 'HH:mm'
 | 
				
			||||||
    this.language = 'en-us'
 | 
					    this.language = 'en-us'
 | 
				
			||||||
    this.podcastSearchRegion = 'us'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.logLevel = Logger.logLevel
 | 
					    this.logLevel = Logger.logLevel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -110,7 +109,6 @@ class ServerSettings {
 | 
				
			|||||||
    this.dateFormat = settings.dateFormat || 'MM/dd/yyyy'
 | 
					    this.dateFormat = settings.dateFormat || 'MM/dd/yyyy'
 | 
				
			||||||
    this.timeFormat = settings.timeFormat || 'HH:mm'
 | 
					    this.timeFormat = settings.timeFormat || 'HH:mm'
 | 
				
			||||||
    this.language = settings.language || 'en-us'
 | 
					    this.language = settings.language || 'en-us'
 | 
				
			||||||
    this.podcastSearchRegion = settings.podcastSearchRegion || 'us'
 | 
					 | 
				
			||||||
    this.logLevel = settings.logLevel || Logger.logLevel
 | 
					    this.logLevel = settings.logLevel || Logger.logLevel
 | 
				
			||||||
    this.version = settings.version || null
 | 
					    this.version = settings.version || null
 | 
				
			||||||
    this.buildNumber = settings.buildNumber || 0 // Added v2.4.5
 | 
					    this.buildNumber = settings.buildNumber || 0 // Added v2.4.5
 | 
				
			||||||
@ -200,7 +198,6 @@ class ServerSettings {
 | 
				
			|||||||
      dateFormat: this.dateFormat,
 | 
					      dateFormat: this.dateFormat,
 | 
				
			||||||
      timeFormat: this.timeFormat,
 | 
					      timeFormat: this.timeFormat,
 | 
				
			||||||
      language: this.language,
 | 
					      language: this.language,
 | 
				
			||||||
      podcastSearchRegion: this.podcastSearchRegion,
 | 
					 | 
				
			||||||
      logLevel: this.logLevel,
 | 
					      logLevel: this.logLevel,
 | 
				
			||||||
      version: this.version,
 | 
					      version: this.version,
 | 
				
			||||||
      buildNumber: this.buildNumber,
 | 
					      buildNumber: this.buildNumber,
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,6 @@
 | 
				
			|||||||
const axios = require('axios')
 | 
					const axios = require('axios')
 | 
				
			||||||
const Logger = require('../Logger')
 | 
					const Logger = require('../Logger')
 | 
				
			||||||
const htmlSanitizer = require('../utils/htmlSanitizer')
 | 
					const htmlSanitizer = require('../utils/htmlSanitizer')
 | 
				
			||||||
const Database = require('../Database')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class iTunes {
 | 
					class iTunes {
 | 
				
			||||||
  constructor() { }
 | 
					  constructor() { }
 | 
				
			||||||
@ -18,7 +17,7 @@ class iTunes {
 | 
				
			|||||||
      entity: options.entity,
 | 
					      entity: options.entity,
 | 
				
			||||||
      lang: options.lang,
 | 
					      lang: options.lang,
 | 
				
			||||||
      limit: options.limit,
 | 
					      limit: options.limit,
 | 
				
			||||||
      country: options.country ? options.country : Database.serverSettings.podcastSearchRegion
 | 
					      country: options.country
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return axios.get('https://itunes.apple.com/search', { params: query }).then((response) => {
 | 
					    return axios.get('https://itunes.apple.com/search', { params: query }).then((response) => {
 | 
				
			||||||
      return response.data.results || []
 | 
					      return response.data.results || []
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user