mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 11:06:16 -08:00
fix: set custom user agent for channels
This commit is contained in:
1 parent
122d031049
commit
984615d766
3 files changed
+27
-27
No files matched your search
+6
-2
@@ -150,8 +150,11 @@ export class Api {
|
||||
.on(
|
||||
CHANNEL_SET_USER_AGENT,
|
||||
(_event, args: { userAgent: string; referer?: string }) => {
|
||||
if (args.userAgent && args.referer) {
|
||||
this.setUserAgent(args.userAgent, args.referer);
|
||||
if (args.userAgent && args.referer !== undefined) {
|
||||
this.setUserAgent(
|
||||
args.userAgent,
|
||||
args.referer || 'localhost'
|
||||
);
|
||||
} else {
|
||||
this.setUserAgent(this.defaultUserAgent, 'localhost');
|
||||
}
|
||||
@@ -281,6 +284,7 @@ export class Api {
|
||||
* @param referer referer to use
|
||||
*/
|
||||
setUserAgent(userAgent: string, referer?: string): void {
|
||||
console.log('here we go', userAgent);
|
||||
if (userAgent === undefined || userAgent === null || userAgent === '') {
|
||||
userAgent = this.defaultUserAgent;
|
||||
}
|
||||
|
||||
@@ -12,15 +12,10 @@ import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { StorageMap } from '@ngx-pwa/local-storage';
|
||||
import {
|
||||
Observable,
|
||||
combineLatestWith,
|
||||
filter,
|
||||
skipWhile,
|
||||
switchMap,
|
||||
} from 'rxjs';
|
||||
import { Observable, combineLatestWith, filter, map, switchMap } from 'rxjs';
|
||||
import { Channel } from '../../../../../shared/channel.interface';
|
||||
import {
|
||||
CHANNEL_SET_USER_AGENT,
|
||||
ERROR,
|
||||
PLAYLIST_PARSE_BY_URL,
|
||||
PLAYLIST_PARSE_RESPONSE,
|
||||
@@ -35,7 +30,6 @@ import {
|
||||
selectActive,
|
||||
selectChannels,
|
||||
selectCurrentEpgProgram,
|
||||
selectPlaylistTitle,
|
||||
} from '../../../state/selectors';
|
||||
import { MultiEpgContainerComponent } from '../multi-epg/multi-epg-container.component';
|
||||
|
||||
@@ -68,11 +62,6 @@ export class VideoPlayerComponent implements OnInit, OnDestroy {
|
||||
showCaptions: false,
|
||||
};
|
||||
|
||||
/** Title of the current playlist */
|
||||
playlistTitle$ = this.store
|
||||
.select(selectPlaylistTitle)
|
||||
.pipe(skipWhile((playlistFilename) => playlistFilename === ''));
|
||||
|
||||
/** IPC Renderer commands list with callbacks */
|
||||
commandsList = [
|
||||
{
|
||||
@@ -141,7 +130,20 @@ export class VideoPlayerComponent implements OnInit, OnDestroy {
|
||||
playlistId: params.id,
|
||||
})
|
||||
);
|
||||
return this.playlistsService.getPlaylistChannels(params.id);
|
||||
return this.playlistsService.getPlaylist(params.id).pipe(
|
||||
map((playlist) => {
|
||||
if (playlist.userAgent) {
|
||||
this.dataService.sendIpcEvent(
|
||||
CHANNEL_SET_USER_AGENT,
|
||||
{
|
||||
referer: 'localhost',
|
||||
userAgent: playlist.userAgent,
|
||||
}
|
||||
);
|
||||
}
|
||||
return playlist.playlist.items;
|
||||
})
|
||||
);
|
||||
} else if (queryParams.url) {
|
||||
return this.store.select(selectChannels);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { parse } from 'iptv-playlist-parser';
|
||||
import { NgxIndexedDBService } from 'ngx-indexed-db';
|
||||
import { combineLatest, map, Observable, switchMap } from 'rxjs';
|
||||
import { combineLatest, map, switchMap } from 'rxjs';
|
||||
import { Channel } from '../../../shared/channel.interface';
|
||||
import { GLOBAL_FAVORITES_PLAYLIST_ID } from '../../../shared/constants';
|
||||
import {
|
||||
@@ -40,19 +40,12 @@ export class PlaylistsService {
|
||||
return this.dbService.add(DbStores.Playlists, playlist);
|
||||
}
|
||||
|
||||
getPlaylistChannels(id: string) {
|
||||
let playlist$: Observable<Partial<Playlist>>;
|
||||
getPlaylist(id: string) {
|
||||
if (id === GLOBAL_FAVORITES_PLAYLIST_ID) {
|
||||
playlist$ = this.getPlaylistWithGlobalFavorites();
|
||||
return this.getPlaylistWithGlobalFavorites();
|
||||
} else {
|
||||
playlist$ = this.dbService.getByID<Playlist>(
|
||||
DbStores.Playlists,
|
||||
id
|
||||
);
|
||||
return this.dbService.getByID<Playlist>(DbStores.Playlists, id);
|
||||
}
|
||||
return playlist$.pipe(
|
||||
map((data: Playlist) => data.playlist.items as Channel[])
|
||||
);
|
||||
}
|
||||
|
||||
deletePlaylist(playlistId: string) {
|
||||
@@ -84,6 +77,7 @@ export class PlaylistsService {
|
||||
...playlist,
|
||||
title: updatedPlaylist.title,
|
||||
autoRefresh: updatedPlaylist.autoRefresh,
|
||||
userAgent: updatedPlaylist.userAgent,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user