Skip to content

Instantly share code, notes, and snippets.

🍊

cosven cosven

🍊
View GitHub Profile
@cosven
cosven / .fuorc.py
Created May 15, 2020
右键找相似
View .fuorc.py
def add_download_action(ctx):
from fuocore import aio
from fuocore.models import ModelType, SearchType
global app
def sample(models):
for model in models:
if model.meta.model_type == ModelType.song:
print(str(model))
View .fuorc.py
# -*- mode: Python; -*-
# vi: ft=python
import json
import os
import threading
from functools import partial
config.AUDIO_SELECT_POLICY = 'sq>>>'
@cosven
cosven / mpv_qtwidget_opengl.py
Last active Apr 25, 2020
mpvwidget implemented with PyQt5 and QOpenGLWidget (currently used in http://github.com/cosven/feeluown)
View mpv_qtwidget_opengl.py
# BSD 3-Clause License
#
# Copyright (c) 2020, Cosven
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
@cosven
cosven / run_sql.py
Last active Feb 25, 2020
一个方便测试 sql 的脚本,配合 ipython notebook 使用味道更佳...
View run_sql.py
"""
这个脚本的好处:运行 sql 并能看到 sql 的输出,输出格式类似 mysql client
比如,运行下面这个脚本,会有如下输出。
```
i j
1 3
(1062, "Duplicate entry '1' for key 'PRIMARY'")
i j
1 2
@cosven
cosven / test.markdown
Created Feb 15, 2020
cmd 支持不同格式输出 - 方案性能对比
View test.markdown

简单的测试了下时间,目前 4k 首歌曲,大概是这么个情况。

In [16]: start = time.time()
    ...: get_dumper('json').dump(songs)
    ...: print(time.time() - start)
0.3063631057739258

In [17]: start = time.time()
    ...: get_dumper('json').dump(songs)
@cosven
cosven / test.py
Last active Feb 10, 2020
profiling playlist_add fuocore.SongModel
View test.py
import cProfile
from fuocore.models import SongModel
songs_10k = [SongModel(identifier=i) for i in range(0, 4000)]
songs = []
def playlist_add(song):
if song not in songs:
songs.append(song)
@cosven
cosven / youtube_provider.py
Created Feb 6, 2020
FeelUOwn YouTube provider
View youtube_provider.py
import os
import time
import json
import subprocess
from fuocore.provider import AbstractProvider
from fuocore.models import SongModel
no_proxy_list = [
@cosven
cosven / t.py
Last active Jan 27, 2020
导出网易云音乐歌单到 fuo 文件
View t.py
"""
Usage:
1. 在 FeelUOwn 中登录网易云
2. fuo exec < t.py
"""
from fuo_netease import provider
from fuocore.models.uri import reverse
from fuocore.cmds.helpers import show_song
@cosven
cosven / extract_sql.py
Created Nov 14, 2019
parse sql statements from general logs
View extract_sql.py
#!/usr/bin/env python3
import re
def get_key_value(key, line):
"""get key's value in log line"""
p = re.compile(r'\[{}\='.format(key))
m = p.search(line)
if m is None:
@cosven
cosven / asyncio_douban_zufang.py
Last active Oct 26, 2019
北京豆瓣租房小脚本...
View asyncio_douban_zufang.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
豆瓣租房爬虫
Install:
pip install beautifulsoup4
Usage:
You can’t perform that action at this time.