Coder Social home page Coder Social logo

timothyye / bing-wallpaper Goto Github PK

View Code? Open in Web Editor NEW
320.0 4.0 34.0 2.83 MB

A RESTful API to fetch daily wallpaper from Bing.com

Home Page: https://bing.biturl.top/

License: Apache License 2.0

Dockerfile 8.79% Makefile 3.76% Go 87.45%
bing-wallpaper bing-wallpaper-api

bing-wallpaper's Introduction

Bing Wallpaper API

A RESTful API to fetch daily wallpaper from Bing.com

Usage

API

Parameters

  • resolution The resolution of wallpaper image. 1920 is the default value, you can also use 1366 and 3840(4K resolution).
  • format The response format, can be json or image. If response format is set as image, you will be redirected to the wallpaper image directly.
  • image_format The format of the wallpaper image, available values are jpg or webp. The default value is jpg.
  • index The index of wallpaper, starts from 0. By default, 0 means to get today's image, 1 means to get the image of yesterday, and so on. Or you can specify it as random to choose a random index between 0 and 7.
  • mkt The region parameter, the default value is zh-CN, you can also use en-US, ja-JP, en-AU, en-GB, de-DE, en-NZ, en-CA. You can also set it as random to choose the region randomly.

Example

  • Request
https://bing.biturl.top/?resolution=1920&format=json&index=0&mkt=zh-CN
  • Response
{
  "start_date": "20181118",
  "end_date": "20181119",
  "url": "https://www.bing.com/az/hprichbg/rb/NarrowsZion_ZH-CN9686302838_1920x1080.jpg",
  "copyright": "锡安国家公园内的维尔京河,美国犹他州 (© Justinreznick/Getty Images)",
  "copyright_link": "http://www.bing.com/search?q=%E9%94%A1%E5%AE%89%E5%9B%BD%E5%AE%B6%E5%85%AC%E5%9B%AD\\u0026form=hpcapt\\u0026mkt=zh-cn"
}

CSS background image

You can also use this API to set CSS background image:

background-image: url(https://bing.biturl.top/?resolution=1920&format=image&index=0&mkt=zh-CN);
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;

Demo

https://biturl.top

https://github.com/TimothyYe/biturl/blob/master/screenshots/1.jpg?raw=true

Run with docker

Get the latest version of docker image:

docker pull timothyye/bing:latest

Start the container with the image name & tag (YYYYMMDD or latest), for example:

docker run -d --name=bing-wallpaper --restart=always -p 9000:9000 timothyye/bing:latest

For development

Build it

git clone https://github.com/TimothyYe/bing-wallpaper.git
make build

Run it

bw/bw run

bing-wallpaper's People

Contributors

dependabot[bot] avatar joetsoi avatar julrouxxx avatar mashirozx avatar mingcheng avatar radiergummi avatar timothyye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bing-wallpaper's Issues

Feature Request: webp image format support

First, thanks for the very useful service. I really appreciate it.

I noticed that Bing seems to support delivering WebP images instead of JPEG if you just change the file extension in the URL to the image. However, when using format=image in CSS I can't think of a way to access the WebP version of the image. Maybe a new query string parameter like image_format could be added with values like (jpg and webp) so we could request the WebP version directly to save a few bytes?

Unfortunately, go isn't a language I know, or else I would send a PR.

能否让index和mkt支持random

类似于

https://bing.biturl.top/?resolution=1920&format=image&index=random&mkt=random

返回随机地区随机日期的图片。

What does index parameter do?

Hi, thanks for your web service. What exactly does the index parameter do? If I change it I sometimes get another image, sometimes the same. What is the range of the parameter? Do I need to change it daily? Or is the image changing every day without the index parameter?

Thanks

[Enhancement] Image Title Field

That would be great if you could add title field as well. (As per your convenience)
I could have made a pull request but I don't have an env for go and There are only couple of lines needed, I guess. :)

404

Looks like it stopped working? I get a 404 not found response.

使用 Python 调用接口报错

你好, 我使用 Python 调用你的接口, 报如下的错误:

Traceback (most recent call last):
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
    raise err
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connection.py", line 353, in connect
    conn = self._new_conn()
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000002045BDC95E0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='bing.biturl.top', port=443): Max retries exceeded with url: /?resolution=3840 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002045BDC95E0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\erdong\bin\wallpaper.py", line 21, in <module>
    bing()
  File "C:\Users\erdong\scripts\py\wp\bg.py", line 18, in bing
    with session.get(url) as pic_info:
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\requests\sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\erdong\Dev\Scoop\apps\python\current\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='bing.biturl.top', port=443): Max retries exceeded with url: /?resolution=3840 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002045BDC95E0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))

Python 版本

Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

URL blocked by antivirus

It appears that AVG Antivirus has blacklisted your URL, bing.biturl.top. I'm not sure how to fix this, just thought I'd let you know.

Bypass CORS

Is it possible for you to change the API so it can be accessed without CORS? I get the following error on a local site (I am working on a chrome extension)

Access to fetch at 'https://bing.biturl.top/?resolution=3840&mkt=en-US' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Wallpaper orientation

Is there a way to change format of the image. I mean, to have it in vericatal format rather than landscape. Similar to what we get from the bing android app/launcher.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.