Skip to content

Commit

Permalink
added option to modify the motrix port, fixes: #122
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamkrishnar committed May 5, 2023
1 parent fb5254d commit 33af50c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ You must download and install the Motrix download manager first to use this exte

## How to use
1. Open the Motrix download manager installed on your computer, and go to `Preferences > Advanced > Security > RPC secret` and create a random secret key and copy it.
There is also an option to update the RPC Listen Port, you dont have to do it. If you are updating it please make sure that you set it to the extension using the set port option in the extension.

<img src="https://user-images.githubusercontent.com/8397274/211193332-bc815b60-60a3-445c-bb0b-7547d1974de8.png" alt="how to use motrix step 1" valign="middle">

Expand Down
4 changes: 4 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@
"downloadWithMotrix": {
"message": "Download with Motrix",
"description": "Download with Motrix"
},
"setPort": {
"message": "Set Port",
"description": "Set Port"
}
}
4 changes: 4 additions & 0 deletions app/_locales/zh/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@
"darkMode": {
"message": "深色模式",
"description": "深色模式"
},
"setPort": {
"message": "设定埠",
"description": "设定埠"
}
}
10 changes: 3 additions & 7 deletions app/scripts/AriaDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function onGot(result, downloadItem, history) {
// API Key is set, Proceed with download
const options = {
host: '127.0.0.1',
port: 16800,
port: result.motrixPort,
secure: false,
secret: result.motrixAPIkey,
path: '/jsonrpc',
Expand Down Expand Up @@ -120,9 +120,7 @@ async function onGot(result, downloadItem, history) {
const status = null;
try {
status = await aria2.call('tellStatus', guid.gid);
} catch {

}
} catch {}
history.set(guid.gid, {
gid: guid.gid,
downloader: 'aria',
Expand All @@ -142,9 +140,7 @@ async function onGot(result, downloadItem, history) {
const status = null;
try {
status = await aria2.call('tellStatus', guid.gid);
} catch {

}
} catch {}
history.set(guid.gid, {
gid: guid.gid,
downloader: 'aria',
Expand Down
1 change: 1 addition & 0 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async function downloadAgent() {
'enableDownloadPrompt',
'minFileSize',
'blacklist',
'motrixPort',
]);

const getAriaDownloader = async (options) => {
Expand Down
31 changes: 29 additions & 2 deletions app/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function ConfigView() {
const [showOnlyAriaDownloads, setShowOnlyAriaDownloads] = useState(false);
const [hideChromeBar, setHideChromeBar] = useState(true);
const [showContextOption, setShowContextOption] = useState(true);
const [motrixPort, setMotrixPort] = useState(16800);

useEffect(() => {
browser.storage.sync
Expand All @@ -38,6 +39,7 @@ function ConfigView() {
'showOnlyAria',
'hideChromeBar',
'showContextOption',
'motrixPort',
])
.then(
(result) => {
Expand Down Expand Up @@ -105,13 +107,18 @@ function ConfigView() {
} else {
setHideChromeBar(result.hideChromeBar);
}

if (typeof result.showContextOption === 'undefined') {
browser.storage.sync.set({ showContextOption: true });
setShowContextOption(true);
} else {
setShowContextOption(result.showContextOption);
}
if (typeof result.motrixPort === 'undefined') {
browser.storage.sync.set({ motrixPort: 16800 });
setMotrixPort(16800);
} else {
setMotrixPort(result.motrixPort);
}
},
(error) => {
console.error(`Error: ${error}`);
Expand Down Expand Up @@ -142,7 +149,27 @@ function ConfigView() {
__MSG_setKey__
</Button>
</Grid>

{/* Motrix port input */}
<Grid item xs={6}>
<TextField
id="motrix-port"
label="__MSG_setPort__"
variant="outlined"
type="number"
fullWidth
value={motrixPort}
onChange={(e) => setMotrixPort(Number(e.target.value))}
/>
</Grid>
<Grid item xs={2}>
<Button
variant="outlined"
style={{ width: '100%', height: '100%' }}
onClick={() => browser.storage.sync.set({ motrixPort })}
>
__MSG_setPort__
</Button>
</Grid>
{/* Minimum file size input */}
<Grid item xs={6}>
<TextField
Expand Down

0 comments on commit 33af50c

Please sign in to comment.