由于您已超出配额,因此无法完成请求

时间:2019-10-20 00:58:12

标签: javascript react-native youtube-data-api quota

由于某些原因,我尝试使用javascript MediaUploader.js将youtube视频上传到自己的帐户,

import React from "react";
import ResultTable from "./ResultTable";
...
import DropdownButton from "react-bootstrap/DropdownButton";
import Dropdown from "react-bootstrap/Dropdown";

class MainContainer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
     //more state values
      threshold: 0.75
    };
    this.thresholdChange = this.thresholdChange.bind(this);
  }
  thresholdChange(input) {
    this.setState({
      threshold: input
    });
  }

  toProperCase = function (txt) {
    return txt.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); });
  };

  render() {
    const { responseData } = this.state;
    return (
      <div className="container-flex container-without-scroll wrapper"     
      style={{
        backgroundImage: `url(${bg})`,
        width: "100%",
        height: "100vh",
        backgroundSize: "cover",
        backgroundRepeat: "no-repeat",
        overFlow:'hidden'
      }}
    >
            <div
              className={`container-fluid `}>                        
              {this.state.displayTable ? (
                <Navbar
                  style={{
                    position: "fixed",
                    left: "50%",
                    top: "95%",
                    transform: "translate(-50%, -90%)",
                    backgroundColor: 'black'
                  }}
                  sticky="bottom"
                >
                   <br />
                  <Navbar.Collapse className="justify-content-end">

                    <Button
                      variant="primary"
                      disabled={
                        this.props.initialTransaction &&
                          this.props.initialTransaction.version == 0 &&
                          this.props.initialTransaction
                          ? true
                          : false
                      }

                      size="sm"
                      style={{ color: "#FFF" }}
                      onClick={this.undoAction}
                    >
                      <span className=" fa fa-undo "></span>
                      &nbsp;Undo
                  </Button>
                    &nbsp;  &nbsp;

                  <Button
                      variant="primary"
                      size="sm"
                      style={{ color: "#FFF" }}
                      disabled={
                        (this.props.initialTransaction &&
                          this.props.initialTransaction.version) <
                          (this.props.currentVersion &&
                            this.props.currentVersion.version)
                          ? false
                          : true
                      }
                      onClick={this.redoAction}
                    >
                      <span className=" fa fa-repeat "></span>
                      &nbsp;Redo
                  </Button>
                    &nbsp;  &nbsp;
                  <Button
                      variant="success"
                      size="sm"
                      style={{ color: "#FFF" }}
                      disabled={
                        this.props.initialTransaction &&
                          this.props.initialTransaction.version == 0
                          ? true
                          : false
                      }
                      onClick={() =>
                        this.exportExcel(this.props.initialTransaction)
                      }
                    >
                      <span className=" fa fa-download "></span>
                      &nbsp;Export
                  </Button>
                  &nbsp;&nbsp; <DropdownButton
                        size="md"
                        title={this.state.threshold}
                      >&nbsp;
                        {this.state.thresholdValues.map(eachValue => {
                        return (
                          <Dropdown.Item
                            key = {Math.random()}
                            onClick={() => this.thresholdChange(eachValue)}
                            as="button"
                          >
                            {eachValue}
                          </Dropdown.Item>
                        );
                      })}
                      </DropdownButton>
                  </Navbar.Collapse>
                  <br/>
                </Navbar>
              ) : null}

              {this.state.displayTable ? null : (
                <div
                  className="col-md-4 col-md-offset-4"
                  style={{
                    position: "absolute",
                    left: "50%",
                    top: "50%",
                    transform: "translate(-50%, -50%)",
                    backgroundColor: 'rgba(14, 13, 13, 0.74)'
                  }}
                >
                  <br />
                  <div className="row">
                    <div className="input-group col-md-9">
                      &nbsp;&nbsp;
                      <div className="input-group-prepend">
                        <span
                        style={{ cursor: 'pointer' }}
                          onClick={this.onFormSubmit}
                          className="input-group-text"
                          id="inputGroupFileAddon01"
                        >
                          {" "}
                          Upload{" "}
                        </span>
                      </div>
                      <div className="custom-file">
                        <input
                          type="file"
                          className="custom-file-input"
                          id="inputGroupFile01"
                          onChange={this.onChange}
                          aria-describedby="inputGroupFileAddon01"
                        />
                        <label
                          className="custom-file-label"
                          htmlFor="inputGroupFile01"
                        >
                          {this.props.active && this.props.active.filename}
                        </label>
                      </div>
                    </div>
                    <div className="col-md-3">
                      <DropdownButton
                        size="md"
                        id="dropdown-item-button"
                        title={this.state.threshold}
                      >&nbsp;
                        {this.state.thresholdValues.map(eachValue => {
                        return (
                          <Dropdown.Item
                            onClick={() => this.thresholdChange(eachValue)}
                            as="button"
                          >
                            {eachValue}
                          </Dropdown.Item>

                        );
                      })}
                      </DropdownButton>

                    </div>

                  </div>
                  <br />
                </div>
              )}
                <div >
                  {this.state.displayTable ? (
                    <div className = "container-flex" style = 
              {{overflowY:'scroll', maxHeight:'80vh'}}>
                    <ResultTable
                      data={responseData}
                      afterMerge={params => {
                        this.afterMerge(params);
                      }}
                    />
                    </div>
                  ) : null}
                </div>
              </div>
        </div>
        );
      }
    }

    // Maps state from store to props
const mapStateToProps = (state, ownProps) => {
  return {

      };
    };

    // Maps actions to props
const mapDispatchToProps = dispatch => {
  return {

      };
    };

    // Use connect to put them together
    export default connect(
      mapStateToProps,
      mapDispatchToProps
    )(MainContainer);

我今天只测试了几次,但出现了这个奇怪的错误。

"errors": [
   {
    "domain": "youtube.quota",
    "reason": "quotaExceeded",
    "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e."
   }
  ],
  "code": 403,
  "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e."

};

我检查了配额的开发者控制台,配额限制太大,没有办法超过配额,例如,今天我总共有89个查询,而每天的配额限制是10,000个查询。

预期:将视频成功上传到我的youtube帐户。 实际结果:quotaExceeded

2 个答案:

答案 0 :(得分:1)

Youtube每天不会给您10,000个查询,而是每天给您10,000个单位;一个查询可以有多个单位,具体取决于您的工作:

  

一个简单的读取操作,仅检索每个返回的ID   资源的成本约为1个单位。

     

一次写操作的成本约为50个单位。

     

视频上传的成本约为1600个单位。

如果您的89个查询是视频上传,则可以解释您的问题

更多信息: https://developers.google.com/youtube/v3/getting-started#quota

答案 1 :(得分:1)

损坏的 Google 开发者项目 - 创建一个新项目

我对 Google 感到失望,因为我就是这种情况。

<块引用>

我遇到了同样的问题,除了“配额超出”响应外,根本没有使用。我的解决方案是创建一个新项目。我想这是因为随着时间的推移,内部发生了一些变化,并且没有正确应用于(至少是我的)已经存在的项目......

出于多种原因,我已经停止使用 AWS,并认为 Google Cloud 将是一种令人耳目一新的体验,但这表明 Google 将现有项目视为它杀死的新产品一样糟糕。与 Google 一决高下。

https://github.com/googleapis/google-api-nodejs-client/issues/2263#issuecomment-741892605