Skip to content

Commit

Permalink
add/update some sites (#154)
Browse files Browse the repository at this point in the history
* add some sites
---------

Co-authored-by: hxsf <i@hxsf.me>
Co-authored-by: CzBiX <CzBiX@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 16, 2023
1 parent 083b896 commit a28c31e
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 9 deletions.
74 changes: 74 additions & 0 deletions bin/fix-site-icon-size.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable no-console */
import path from 'path'
import fs from 'fs/promises'
import { execSync } from 'child_process'

const ICON_DIR = 'src/assets/site_icons'
const ICON_SIZE = 48

function execShell(command) {
const output = execSync(command)
return output.toString().trim()
}

function isIconFile(iconPath) {
const output = execShell(`file -b --mime-type ${iconPath}`)
return output.includes('image/vnd.microsoft.icon')
}

function getIconIndex(iconPath) {
const output = execShell(`magick identify -format "%s:%w\\n" ${iconPath}`)
let lastIndex = 0
for (const line of output.split('\n')) {
const [index, width] = line.split(':')
const size = parseInt(width)
if (size >= ICON_SIZE) {
return index
}

lastIndex = index
}

return lastIndex
}

function convertIcon(iconPath, outputPath) {
const iconIndex = getIconIndex(iconPath)
execShell(`magick convert -thumbnail "${ICON_SIZE}x${ICON_SIZE}>" ${iconPath}[${iconIndex}] ${outputPath}`)
}

async function fixSiteIcon(name) {
const iconPath = path.join(ICON_DIR, name)
if (!isIconFile(iconPath)) {
return
}

const tmpPath = path.join(ICON_DIR, '_tmp.ico')
await fs.copyFile(iconPath, tmpPath)
try {
convertIcon(tmpPath, iconPath)
} finally {
await fs.unlink(tmpPath)
}

console.log(`Converted ${name}`)
}

async function main() {
let files = []
if (process.argv.length > 2) {
files = process.argv.slice(2)
} else {
files = await fs.readdir(ICON_DIR)
}

files = files.filter(name => {
return name.endsWith('.png')
})

for (const name of files) {
await fixSiteIcon(name)
}
}

main()
Binary file added src/assets/site_icons/2xfree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/site_icons/chdbits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/hares.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/hdsky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/hdtime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/kamept.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/lemonhd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/opencd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/ourbits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/pterclub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/pthome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/ptsbao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/pttime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/soulvoice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/site_icons/springsunday.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/site_icons/totheglory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/site_icons/u2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions src/components/Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</template>

<script lang="ts">
import { sortBy, sumBy, defaultTo, isUndefined } from 'lodash';
import { sortBy, sumBy, isUndefined } from 'lodash';
import Vue from 'vue';
import { mapGetters } from 'vuex';
Expand Down Expand Up @@ -132,6 +132,14 @@ interface MenuChildrenItem extends MenuItem {
append?: string;
}
function getTopDomain(host: string) {
const parts = host.split('.');
if (parts.length > 2) {
return parts.slice(-2).join('.');
}
return host;
}
@Component({
components: {
FilterGroup,
Expand Down Expand Up @@ -239,9 +247,10 @@ export default class Drawer extends Vue {
buildSiteGroup(): MenuChildrenItem[] {
return sortBy(Object.entries(this.torrentGroupBySite).map(([key, value]) => {
const size = formatSize(sumBy(value, 'size'));
const site = SiteMap[key];
const domain = getTopDomain(key);
const site = SiteMap[domain];
const title = `${site ? site.name : (key || tr('others'))} (${value.length})`;
const icon = defaultTo(site ? site.icon : null, 'mdi-server');
const icon = site?.icon ?? 'mdi-server';
const append = `[${size}]`;
return {
icon, title, key, append,
Expand Down
106 changes: 100 additions & 6 deletions src/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ function getSiteIcon(name: string): string {

export interface SiteInfo {
name: string;
icon: string;
icon?: string;
}

const sites: {[key: string]: SiteInfo} = {
'tracker.m-team.cc': {
'm-team.cc': {
name: 'M-Team',
icon: getSiteIcon('m-team'),
},
'tracker.keepfrds.com': {
name: 'FRDS',
'keepfrds.com': {
name: 'PT@KEEPFRDS',
icon: getSiteIcon('keepfrds'),
},
'springsunday.net': {
Expand All @@ -30,12 +30,106 @@ const sites: {[key: string]: SiteInfo} = {
},
'hdhome.org': {
name: 'HDHome',
icon: getSiteIcon('hdhome'),
icon: getSiteIcon('nexusphp'),
},
'u2.dmhy.org': {
'dmhy.org': {
name: 'U2',
icon: getSiteIcon('u2'),
},
'dmhy.best': {
name: 'U2',
icon: getSiteIcon('u2'),
},
'totheglory.im': {
name: 'TTG',
icon: getSiteIcon('totheglory'),
},
'oshen.win': {
name: 'OshenPT',
icon: getSiteIcon('nexusphp'),
},
'soulvoice.club': {
name: '铃音Club',
icon: getSiteIcon('soulvoice'),
},
'ourbits.club': {
name: 'OurBits',
icon: getSiteIcon('ourbits'),
},
'btschool.club': {
name: 'BTSCHOOL',
},
'ptsbao.club': {
name: '烧包',
icon: getSiteIcon('ptsbao'),
},
'pterclub.com': {
name: 'PTer',
icon: getSiteIcon('pterclub'),
},
'hdtime.org': {
name: 'HDTime',
icon: getSiteIcon('hdtime'),
},
'hddolby.com': {
name: 'HD Dolby',
},
'lemonhd.org': {
name: 'LemonHD',
icon: getSiteIcon('lemonhd'),
},
'hares.top': {
name: 'HaresClub',
icon: getSiteIcon('hares'),
},
'pthome.net': {
name: 'PTHOME',
icon: getSiteIcon('pthome'),
},
'hdsky.me': {
name: 'HDSky',
icon: getSiteIcon('hdsky'),
},
'hdfans.org': {
name: 'HDFans',
icon: getSiteIcon('nexusphp'),
},
'hdatmos.club': {
name: 'HDAtmos',
icon: getSiteIcon('nexusphp'),
},
'hdzone.me': {
name: 'HDZone',
icon: getSiteIcon('nexusphp'),
},
'open.cd': {
name: 'OpenCD',
icon: getSiteIcon('opencd'),
},
'1ptba.com': {
name: '1PTBar',
icon: getSiteIcon('nexusphp'),
},
'pttime.org': {
name: 'PTTime',
icon: getSiteIcon('pttime'),
},
'beitai.pt': {
name: '备胎',
icon: getSiteIcon('nexusphp'),
},
'kamept.com': {
name: 'kamept',
icon: getSiteIcon('kamept'),
},
'nicept.net': {
name: 'NicePT',
icon: getSiteIcon('nexusphp'),
},
'2xfree.org': {
name: '2xfree',
icon: getSiteIcon('2xfree'),
},
};

export default sites;

0 comments on commit a28c31e

Please sign in to comment.