Skip to content

Commit

Permalink
✨Feature update
Browse files Browse the repository at this point in the history
 - Updated browser extension manifest_version(2->3)
 - Improved file name specification when saving files by video storage server
 - Updated package
  • Loading branch information
7rikazhexde committed Mar 5, 2024
1 parent 35e4745 commit 29d1988
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 30 deletions.
15 changes: 12 additions & 3 deletions browser_extension/twitter-video-dl-send/background.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
function sendUrl(url, fileName) {
fetch(`http://localhost:3000/?url=${encodeURIComponent(url)}&fileName=${encodeURIComponent(fileName)}`);
let lastError = null;

async function sendUrl(url, fileName) {
await fetch(`http://localhost:3000/?url=${encodeURIComponent(url)}&fileName=${encodeURIComponent(fileName)}`);
}

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "sendUrl") {
sendUrl(request.url, request.fileName);
sendUrl(request.url, request.fileName).catch((error) => {
console.log(error);
lastError = error.message;
});
} else if (request.action === "getLastError") {
sendResponse({error: lastError});
lastError = null;
}
});
22 changes: 11 additions & 11 deletions browser_extension/twitter-video-dl-send/manifest.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "twitter-video-dl-send",
"version": "0.0.1",
"version": "0.0.2",
"author": "7rikaz_h785 <7rikaz.h785.stat2ltas41lcijad@gmail.com>",
"homepage_url": "https://github.com/7rikazhexde/twitter-video-dl-for-sc",
"permissions": ["activeTab", "http://localhost:3000/"],
"permissions": ["activeTab"],
"host_permissions": ["http://localhost:3000/"],
"background": {
"scripts": ["background.js"],
"persistent": false
"service_worker": "background.js"
},
"browser_action": {
"action": {
"default_popup": "popup.html",
"default_width": 400,
"default_height": 200
},
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
}
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
}
}
18 changes: 16 additions & 2 deletions browser_extension/twitter-video-dl-send/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ window.addEventListener('DOMContentLoaded', () => {
document.getElementById('sendCurrentUrl').addEventListener('click', function() {
const fileName = document.getElementById('fileNameInput').value;
chrome.tabs.query({active: true, currentWindow: true}, tabs => {
chrome.runtime.sendMessage({action: "sendUrl", url: tabs[0].url, fileName: fileName});
chrome.runtime.sendMessage({action: "sendUrl", url: tabs[0].url, fileName: fileName}).catch((error) => {
console.log(error);
chrome.runtime.sendMessage({action: "getLastError"}, response => {
if (response.error) {
alert(response.error);
}
});
});
});
this.style.backgroundColor = '#888888';
this.innerText = text[languageSelect.value].sent;
Expand All @@ -59,7 +66,14 @@ document.getElementById('sendInputUrl').addEventListener('click', function() {
const url = document.getElementById('urlInput').value;
const fileName = document.getElementById('fileNameInput').value;
if (url) {
chrome.runtime.sendMessage({action: "sendUrl", url: url, fileName: fileName});
chrome.runtime.sendMessage({action: "sendUrl", url: url, fileName: fileName}).catch((error) => {
console.log(error);
chrome.runtime.sendMessage({action: "getLastError"}, response => {
if (response.error) {
alert(response.error);
}
});
});
this.style.backgroundColor = '#888888';
this.innerText = text[languageSelect.value].sent;
setTimeout(() => {
Expand Down
48 changes: 41 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "This project is based on the original code of the [inteoryx / twi
license = "Unlicense"
name = "twitter-video-dl-for-sc"
readme = "README.md"
version = "0.2.8"
version = "0.2.9"

[tool.poetry.dependencies]
python = "^3.11.0"
Expand All @@ -21,6 +21,7 @@ pytest = "^7.4.3"
pytest-mock = "^3.12.0"
pytest-cov = "^4.1.0"
pytest-html = "^4.1.1"
pytest-xdist = "^3.5.0"

[tool.taskipy.tasks]
# poetry run task [task]
Expand Down
18 changes: 12 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ coverage[toml]==7.4.3 ; python_full_version >= "3.11.0" and python_full_version
distlib==0.3.8 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784 \
--hash=sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64
execnet==2.0.2 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:88256416ae766bc9e8895c76a87928c0012183da3cc4fc18016e6f050e025f41 \
--hash=sha256:cc59bc4423742fd71ad227122eb0dd44db51efb3dc4095b45ac9a08c770096af
ffmpeg-python==0.2.0 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:65225db34627c578ef0e11c8b1eb528bb35e024752f6f10b78c011f6f64c4127 \
--hash=sha256:ac441a0404e053f8b6a1113a77c0f452f1cfc62f6344a769475ffdc0f56c23c5
Expand Down Expand Up @@ -262,9 +265,9 @@ markupsafe==2.1.5 ; python_full_version >= "3.11.0" and python_full_version < "4
--hash=sha256:fa9db3f79de01457b03d4f01b34cf91bc0048eb2c3846ff26f66687c2f6d16ab \
--hash=sha256:fce659a462a1be54d2ffcacea5e3ba2d74daa74f30f5f143fe0c58636e355fdd \
--hash=sha256:ffee1f21e5ef0d712f9033568f8344d5da8cc2869dbd08d87c84656e6a2d2f68
mslex==1.1.0 ; python_full_version >= "3.11.0" and python_version < "4.0" and sys_platform == "win32" \
--hash=sha256:7fe305fbdc9721283875e0b737fdb344374b761338a7f41af91875de278568e4 \
--hash=sha256:8826f4bb8d8c63402203d921dc8c2df0c7fec0d9c91d020ddf02fc9d0dce81bd
mslex==1.2.0 ; python_full_version >= "3.11.0" and python_version < "4.0" and sys_platform == "win32" \
--hash=sha256:79e2abc5a129dd71cdde58a22a2039abb7fa8afcbac498b723ba6e9b9fbacc14 \
--hash=sha256:c68ec637485ee3544c5847c1b4e78b02940b32708568fb1d8715491815aa2341
mypy-extensions==1.0.0 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d \
--hash=sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782
Expand Down Expand Up @@ -315,6 +318,9 @@ pytest-metadata==3.1.1 ; python_full_version >= "3.11.0" and python_full_version
pytest-mock==3.12.0 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:0972719a7263072da3a21c7f4773069bcc7486027d7e8e1f81d98a47e701bc4f \
--hash=sha256:31a40f038c22cad32287bb43932054451ff5583ff094bca6f675df2f8bc1a6e9
pytest-xdist==3.5.0 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:cbb36f3d67e0c478baa57fa4edc8843887e0f6cfc42d677530a36d7472b32d8a \
--hash=sha256:d075629c7e00b611df89f490a5063944bee7a4362a5ff11c7cc7824a03dfce24
pytest==7.4.4 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280 \
--hash=sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8
Expand Down Expand Up @@ -389,9 +395,9 @@ taskipy==1.12.2 ; python_full_version >= "3.11.0" and python_version < "4.0" \
tomli==2.0.1 ; python_full_version >= "3.11.0" and python_version < "4.0" \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
tomlkit==0.12.3 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:75baf5012d06501f07bee5bf8e801b9f343e7aac5a92581f20f80ce632e6b5a4 \
--hash=sha256:b0a645a9156dc7cb5d3a1f0d4bab66db287fcb8e0430bdd4664a095ea16414ba
tomlkit==0.12.4 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:5cd82d48a3dd89dee1f9d64420aa20ae65cfbd00668d6f094d7578a78efbb77b \
--hash=sha256:7ca1cfc12232806517a8515047ba66a19369e71edf2439d0f5824f91032b6cc3
urllib3==2.2.1 ; python_full_version >= "3.11.0" and python_full_version < "4.0.0" \
--hash=sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d \
--hash=sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19
Expand Down
1 change: 1 addition & 0 deletions twitter-video-dl-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def do_GET(self):
url = params.get("url", [""])[0]
fileName = params.get("fileName", [""])[0]
if url:
fileName = fileName.replace(" ", "_").replace(" ", "_").replace("/", "-")
tvdl.download_video_for_sc(url, fileName)
self.send_response(200)
self.send_header("Content-type", "text/html")
Expand Down

0 comments on commit 29d1988

Please sign in to comment.