Skip to main content
added 69 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
{   
    "manifest_version": 2   ,
    
    "name": "Adder",
    "description": "Add video's URL to file for future download",
    "version": "1.3.1",
    "icons": { "128": "icons/square_youtube.png"},
    "background": { 
        "scripts": ["background.js"],
        "persistent": false
     },
     
     "permissions": [
        "tabs",
        "downloads",
        "declarativeContent"
    ],
    
    "page_action": { 
        "default_name": "Adder", 
        "default_icon": "icons/square_youtube.png", 
        "default_popup": "popup.html", 
        "default_title": "Add it!"  
    }
}
{   
    "manifest_version": 2   ,
    
    "name": "Adder",
    "description": "Add video's URL to file for future download",
    "version": "1.3.1",
    "icons": { "128": "icons/square_youtube.png"},
    "background": { 
        "scripts": ["background.js"],
        "persistent": false
     },
     
     "permissions": [
        "tabs",
        "downloads",
        "declarativeContent"
    ],
    
    "page_action": { 
        "default_name": "Adder", 
        "default_icon": "icons/square_youtube.png", 
        "default_popup": "popup.html", 
        "default_title": "Add it!"  
    }
}
// Update the declarative rules on install or upgrade.

chrome.runtime.onInstalled.addListener(function() {
    chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
            chrome.declarativeContent.onPageChanged.addRules([{
                conditions: [
                    // When a page contains a <video> tag...
                    new chrome.declarativeContent.PageStateMatcher({
                        css: ["video"]
                    })
                ],
                // ... show the page action.
                actions: [new chrome.declarativeContent.ShowPageAction() ]
            }]);
    });
});
// Update the declarative rules on install or upgrade.

chrome.runtime.onInstalled.addListener(function() {
    chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
            chrome.declarativeContent.onPageChanged.addRules([{
                conditions: [
                    // When a page contains a <video> tag...
                    new chrome.declarativeContent.PageStateMatcher({
                        css: ["video"]
                    })
                ],
                // ... show the page action.
                actions: [new chrome.declarativeContent.ShowPageAction() ]
            }]);
    });
});
var stripThis = "https://www.youtube.com/watch?v=";

chrome.tabs.query({active: true, lastFocusedWindow: true}, function(tabs) {
    var currentUrl = tabs[0].url;
    var smallUrl = currentUrl.substring(stripThis.length, currentUrl.length);
    var pathDL = "URLs/"+smallUrl+".txt";
    
    chrome.downloads.download({url: currentUrl, filename:pathDL}, function(downloadId) {});
});
var stripThis = "https://www.youtube.com/watch?v=";

chrome.tabs.query({active: true, lastFocusedWindow: true}, function(tabs) {
    var currentUrl = tabs[0].url;
    var smallUrl = currentUrl.substring(stripThis.length, currentUrl.length);
    var pathDL = "URLs/"+smallUrl+".txt";
    
    chrome.downloads.download({url: currentUrl, filename:pathDL}, function(downloadId) {});
});
#!/bin/bash
DownloadAndConvert() {
    echo Avvio...
    echo Importo URLs da files...
    echo creo lista unificata...
    cd /home/faceless/Dropbox/URLs/
    count=`ls -1 *.txt 2>/dev/null | wc -l`
    YTBSTR="https://www.youtube.com/watch?v="
    if [ $count != 0 ]; then
        touch mergedList
        for filename in *.txt; do
            echo $YTBSTR$(basename "$filename" .txt) >> mergedList
            if [ $filename != mergedList ]; then
                rm $filename
            fi
        done
        download
        cleanup
    elif [ -e mergedList ]; then
        echo La lista è già presente! - Procedo...
        download
        cleanup
    else
        echo Non ci sono video! - Esco
        exit
    fi
}
download() {
    echo Inizio Scaricamento...
    youtube-dl -x -a "mergedList" --no-playlist 
}

cleanup() {
    echo Pulisco lista...
    rm mergedList
    echo FINE
}

trap exit SIGINT
DownloadAndConvert
#!/bin/bash
DownloadAndConvert() {
    echo Avvio...
    echo Importo URLs da files...
    echo creo lista unificata...
    cd /home/faceless/Dropbox/URLs/
    count=`ls -1 *.txt 2>/dev/null | wc -l`
    YTBSTR="https://www.youtube.com/watch?v="
    if [ $count != 0 ]; then
        touch mergedList
        for filename in *.txt; do
            echo $YTBSTR$(basename "$filename" .txt) >> mergedList
            if [ $filename != mergedList ]; then
                rm $filename
            fi
        done
        download
        cleanup
    elif [ -e mergedList ]; then
        echo La lista è già presente! - Procedo...
        download
        cleanup
    else
        echo Non ci sono video! - Esco
        exit
    fi
}
download() {
    echo Inizio Scaricamento...
    youtube-dl -x -a "mergedList" --no-playlist 
}

cleanup() {
    echo Pulisco lista...
    rm mergedList
    echo FINE
}

trap exit SIGINT
DownloadAndConvert
{   
    "manifest_version": 2   ,
    
    "name": "Adder",
    "description": "Add video's URL to file for future download",
    "version": "1.3.1",
    "icons": { "128": "icons/square_youtube.png"},
    "background": { 
        "scripts": ["background.js"],
        "persistent": false
     },
     
     "permissions": [
        "tabs",
        "downloads",
        "declarativeContent"
    ],
    
    "page_action": { 
        "default_name": "Adder", 
        "default_icon": "icons/square_youtube.png", 
        "default_popup": "popup.html", 
        "default_title": "Add it!"  
    }
}
// Update the declarative rules on install or upgrade.

chrome.runtime.onInstalled.addListener(function() {
    chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
            chrome.declarativeContent.onPageChanged.addRules([{
                conditions: [
                    // When a page contains a <video> tag...
                    new chrome.declarativeContent.PageStateMatcher({
                        css: ["video"]
                    })
                ],
                // ... show the page action.
                actions: [new chrome.declarativeContent.ShowPageAction() ]
            }]);
    });
});
var stripThis = "https://www.youtube.com/watch?v=";

chrome.tabs.query({active: true, lastFocusedWindow: true}, function(tabs) {
    var currentUrl = tabs[0].url;
    var smallUrl = currentUrl.substring(stripThis.length, currentUrl.length);
    var pathDL = "URLs/"+smallUrl+".txt";
    
    chrome.downloads.download({url: currentUrl, filename:pathDL}, function(downloadId) {});
});
#!/bin/bash
DownloadAndConvert() {
    echo Avvio...
    echo Importo URLs da files...
    echo creo lista unificata...
    cd /home/faceless/Dropbox/URLs/
    count=`ls -1 *.txt 2>/dev/null | wc -l`
    YTBSTR="https://www.youtube.com/watch?v="
    if [ $count != 0 ]; then
        touch mergedList
        for filename in *.txt; do
            echo $YTBSTR$(basename "$filename" .txt) >> mergedList
            if [ $filename != mergedList ]; then
                rm $filename
            fi
        done
        download
        cleanup
    elif [ -e mergedList ]; then
        echo La lista è già presente! - Procedo...
        download
        cleanup
    else
        echo Non ci sono video! - Esco
        exit
    fi
}
download() {
    echo Inizio Scaricamento...
    youtube-dl -x -a "mergedList" --no-playlist 
}

cleanup() {
    echo Pulisco lista...
    rm mergedList
    echo FINE
}

trap exit SIGINT
DownloadAndConvert
{   
    "manifest_version": 2   ,
    
    "name": "Adder",
    "description": "Add video's URL to file for future download",
    "version": "1.3.1",
    "icons": { "128": "icons/square_youtube.png"},
    "background": { 
        "scripts": ["background.js"],
        "persistent": false
     },
     
     "permissions": [
        "tabs",
        "downloads",
        "declarativeContent"
    ],
    
    "page_action": { 
        "default_name": "Adder", 
        "default_icon": "icons/square_youtube.png", 
        "default_popup": "popup.html", 
        "default_title": "Add it!"  
    }
}
// Update the declarative rules on install or upgrade.

chrome.runtime.onInstalled.addListener(function() {
    chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
            chrome.declarativeContent.onPageChanged.addRules([{
                conditions: [
                    // When a page contains a <video> tag...
                    new chrome.declarativeContent.PageStateMatcher({
                        css: ["video"]
                    })
                ],
                // ... show the page action.
                actions: [new chrome.declarativeContent.ShowPageAction() ]
            }]);
    });
});
var stripThis = "https://www.youtube.com/watch?v=";

chrome.tabs.query({active: true, lastFocusedWindow: true}, function(tabs) {
    var currentUrl = tabs[0].url;
    var smallUrl = currentUrl.substring(stripThis.length, currentUrl.length);
    var pathDL = "URLs/"+smallUrl+".txt";
    
    chrome.downloads.download({url: currentUrl, filename:pathDL}, function(downloadId) {});
});
#!/bin/bash
DownloadAndConvert() {
    echo Avvio...
    echo Importo URLs da files...
    echo creo lista unificata...
    cd /home/faceless/Dropbox/URLs/
    count=`ls -1 *.txt 2>/dev/null | wc -l`
    YTBSTR="https://www.youtube.com/watch?v="
    if [ $count != 0 ]; then
        touch mergedList
        for filename in *.txt; do
            echo $YTBSTR$(basename "$filename" .txt) >> mergedList
            if [ $filename != mergedList ]; then
                rm $filename
            fi
        done
        download
        cleanup
    elif [ -e mergedList ]; then
        echo La lista è già presente! - Procedo...
        download
        cleanup
    else
        echo Non ci sono video! - Esco
        exit
    fi
}
download() {
    echo Inizio Scaricamento...
    youtube-dl -x -a "mergedList" --no-playlist 
}

cleanup() {
    echo Pulisco lista...
    rm mergedList
    echo FINE
}

trap exit SIGINT
DownloadAndConvert
added 13 characters in body
Source Link

In the bash script, I could most likely just use the videoID instead of the whole URL. I still have to check YouTube-dlyoutube-dl documentation, but it doesn't change much.

In the bash script, I could most likely just use the videoID instead of the whole URL. I still have to check YouTube-dl documentation, but it doesn't change much.

In the bash script, I could most likely just use the videoID instead of the whole URL. I still have to check youtube-dl documentation, but it doesn't change much.

added 10 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Chrome extension to get youtube video's urlURL

I needed something that would get the urlURL of a chosen video from youtubeYouTube and store it in a file. Since i

Since I didn't find a way to write/edit an existing file with the urlURL alone i, I had to use a patchwork of javascriptJavaScript and bash to stitch together the complete urlURL. I'm

I'm asking if there were things iI could have done better or with a different approach. 

Here's the code of the extension:

manifest.json:manifest.json:

background.js:background.js:

popup.jspopup.js (popup.html just call this script):

Let me explain what this does in particular: I

I built a panel_action extentionpanel_action extension that only shows if there is a video in the page. Then if iI click on the icon in the omnibar, the extentionextension download the WHOLE html page in a txt.txt file named after the videoIDvideoID.

Then using a bash script iI take all the names of the files and merge them in a single list.

This system feel a lot clumsy and it is mostly a patchwork of snippets of code took here and there ( especiallyespecially the javascriptJavaScript ones  ). That's That's why i'mI'm asking for insights for improvements!

In the bash script most probably i, I could most likely just use the videoIDvideoID instead of the whole url, iURL. I still have to check youtubeYouTube-dl documentation, but it doesn't change much.

I chose the download location ( withwith some ln hacks  ) in such a way that the videoID.txtvideoID.txt would end up in the same shared folder in dropbox.

Chrome extension to get youtube video's url

I needed something that would get the url of a chosen video from youtube and store it in a file. Since i didn't find a way to write/edit an existing file with the url alone i had to use a patchwork of javascript and bash to stitch together the complete url. I'm asking if there were things i could have done better or with a different approach. Here's the code of the extension:

manifest.json:

background.js:

popup.js (popup.html just call this script):

Let me explain what this does in particular: I built a panel_action extention that only shows if there is a video in the page. Then if i click on the icon in the omnibar, the extention download the WHOLE html page in a txt file named after the videoID.

Then using a bash script i take all the names of the files and merge them in a single list.

This system feel a lot clumsy and it is mostly a patchwork of snippets of code took here and there ( especially the javascript ones  ). That's why i'm asking for insights for improvements!

In the bash script most probably i could just use the videoID instead of the whole url, i still have to check youtube-dl documentation, but it doesn't change much.

I chose the download location ( with some ln hacks  ) in such a way that the videoID.txt would end up in the same shared folder in dropbox.

Chrome extension to get youtube video's URL

I needed something that would get the URL of a chosen video from YouTube and store it in a file.

Since I didn't find a way to write/edit an existing file with the URL alone, I had to use a patchwork of JavaScript and bash to stitch together the complete URL.

I'm asking if there were things I could have done better or with a different approach. 

Here's the code of the extension:

manifest.json:

background.js:

popup.js (popup.html just call this script):

Let me explain what this does in particular:

I built a panel_action extension that only shows if there is a video in the page. Then if I click on the icon in the omnibar, the extension download the WHOLE html page in a .txt file named after the videoID.

Then using a bash script I take all the names of the files and merge them in a single list.

This system feel a lot clumsy and it is mostly a patchwork of snippets of code took here and there (especially the JavaScript ones). That's why I'm asking for insights for improvements!

In the bash script, I could most likely just use the videoID instead of the whole URL. I still have to check YouTube-dl documentation, but it doesn't change much.

I chose the download location (with some ln hacks) in such a way that the videoID.txt would end up in the same shared folder in dropbox.

Removed some chatty stuff
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391
Loading
Source Link
Loading