Rudloff / alltube

Web GUI for youtube-dl
GNU General Public License v3.0
2.94k stars 584 forks source link

How to add analytics to the site? #357

Closed Retro64XYZ closed 1 year ago

Retro64XYZ commented 3 years ago

New issue

Your environment

Please answer these questions when reporting a new issue:

What is your operating system (Windows, Linux, OSX, etc.)?

Linux

What is your web server (Apache, IIS, etc.)?

NGINX

What version of AllTube are you using?

Latest

How did you install AllTube (with Git or with a release package)?

Git

What version of PHP are you using?

7.4.3

What version of Python are you using?

python3.8

What version of youtube-dl are you using?

2021.05.16

Do you get any PHP-related errors in your webserver's logs?

no

What is the content of your config/config.yml file?

--
# Path to your youtube-dl binary
youtubedl: /usr/local/bin/youtube-dl

# Path to your python binary
python: /usr/bin/python

# An array of parameters to pass to youtube-dl
params:
    - --no-warnings
    - --ignore-errors
    - --flat-playlist
    - --restrict-filenames
    - --no-playlist

# True to enable audio conversion
convert: false

# True to enable advanced conversion mode
convertAdvanced: false

# List of formats available in advanced conversion mode
convertAdvancedFormats: [mp3, avi, flv, wav]

# Path to your ffmpeg binary
ffmpeg: /usr/bin/ffmpeg

# ffmpeg logging level.
ffmpegVerbosity: error

# Path to the directory that contains the phantomjs binary.
phantomjsDir: /usr/bin/

# True to disable URL rewriting
uglyUrls: false

# True to stream videos through server
# Set to "ask" if you want to allow it but not enable by default.
stream: false

# True to enable remux mode (merge best audio and best video)
remux: false

# MP3 bitrate when converting (in kbit/s)
audioBitrate: 128

# App name
appName: AllTube Download

# Generic formats supported by youtube-dl
genericFormats:
    best/bestvideo: Best
    bestvideo+bestaudio: Remux best video with best audio
    worst/worstvideo: Worst

# Enable debug mode.
debug: false

# True to enable audio conversion mode by default
defaultAudio: false

# False to disable convert seek functionality
convertSeek: true

Please provide the URL of a video that causes the issue.

Describe your issue

I need to add analytics to the site. I notice you are using csp-builder. Their documentation is not very good. Is there a simple way to add analytics?

The error I see in the console browser is -

Refused to load the script 'https://myscript.com/umami.js' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'script-src-elem' was not explicitly set, so 'default-src' is used as a fallback.

Is there a quick way to fix this?

Thanks, Aaron

Rudloff commented 3 years ago

You need to add new directives to the CSP in CspMiddleware::applyHeader(). What you need to add will depend on the script you are trying to use, so I can't really help you. You can find information about the available directives here.

Retro64XYZ commented 3 years ago

`

`

Would be the script. Is there an easy way to just add the above to be allowed in CSP and for it to survive if I update the application later?

Rudloff commented 3 years ago

No, customizing the CSP is not supported.