mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
feat: support for setting channel HTTP referrer headers for both HTML5 and JS players
This commit introduces support for setting the HTTP referrer headers per channel. The referer is the http-referrer set for each channel in the m3u8 playlist. This feature works for both the HTML5 and JS players. Updates were made to the player-dialog component to handle the referrer headers for the JS player. Corresponding changes to the html-video-player component for the HTML5 player.
This commit is contained in:
2 files changed
+18
-5
No files matched your search
+3
-5
@@ -169,14 +169,12 @@ export class Api {
|
||||
.on(
|
||||
CHANNEL_SET_USER_AGENT,
|
||||
(_event, args: { userAgent: string; referer?: string }) => {
|
||||
if (args.userAgent && args.referer !== undefined) {
|
||||
if (args.userAgent || args.referer !== undefined) {
|
||||
this.setUserAgent(
|
||||
args.userAgent,
|
||||
args.userAgent || 'localhost',
|
||||
args.referer || 'localhost'
|
||||
);
|
||||
} else {
|
||||
this.setUserAgent(this.defaultUserAgent, 'localhost');
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
.on(IS_PLAYLISTS_MIGRATION_POSSIBLE, (event) => {
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
import Hls from 'hls.js';
|
||||
import { Channel } from '../../../../../shared/channel.interface';
|
||||
import { getExtensionFromUrl } from '../../../../../shared/playlist.utils';
|
||||
import { DataService } from '../../../services/data.service';
|
||||
import { CHANNEL_SET_USER_AGENT } from '../../../../../shared/ipc-commands';
|
||||
|
||||
/**
|
||||
* This component contains the implementation of HTML5 based video player
|
||||
@@ -23,6 +25,11 @@ import { getExtensionFromUrl } from '../../../../../shared/playlist.utils';
|
||||
export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
|
||||
/** Channel to play */
|
||||
@Input() channel: Channel;
|
||||
dataService: DataService; // Declare the dataService property
|
||||
|
||||
constructor(dataService: DataService) {
|
||||
this.dataService = dataService; // Inject the DataService
|
||||
}
|
||||
|
||||
/** Video player DOM element */
|
||||
@ViewChild('videoPlayer', { static: true })
|
||||
@@ -63,6 +70,10 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
|
||||
this.hls = new Hls();
|
||||
this.hls.attachMedia(this.videoPlayer.nativeElement);
|
||||
this.hls.loadSource(url);
|
||||
this.dataService.sendIpcEvent(CHANNEL_SET_USER_AGENT, {
|
||||
userAgent: channel.http['user-agent'],
|
||||
referer: channel.http.referrer,
|
||||
});
|
||||
this.handlePlayOperation();
|
||||
} else {
|
||||
console.error('something wrong with hls.js init...');
|
||||
@@ -71,6 +82,10 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
|
||||
url,
|
||||
'video/mp4'
|
||||
);
|
||||
this.dataService.sendIpcEvent(CHANNEL_SET_USER_AGENT, {
|
||||
userAgent: channel.http['user-agent'],
|
||||
referer: channel.http.referrer,
|
||||
});
|
||||
this.videoPlayer.nativeElement.play();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user