-
Notifications
You must be signed in to change notification settings - Fork 96
[Wip] Youtube App #1086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Wip] Youtube App #1086
Conversation
…d videos on YouTube
…uding actions for liking, pinning, and replying to comments, as well as live streaming management
…module files, including improvements to readability and code style consistency
…hentication and sections structure, removing unnecessary code and improving organization
Tagging OptionsShould a new tag be published when this PR is merged?
|
…nd loaders, removing unnecessary code and improving project organization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translate to English.
## Observações | ||
|
||
- Para modificar informações do canal, você deve ser o proprietário do canal ou ter permissões adequadas. | ||
- Para pinar comentários, você deve ser o proprietário do vídeo ou ter permissões adequadas. | ||
- Para acessar dados de analytics, você precisa ter o escopo `yt-analytics.readonly` autorizado. | ||
- Algumas operações exigem tokens de acesso com escopos específicos. | ||
- A API do YouTube tem restrições específicas sobre quais partes podem ser atualizadas em conjunto. Por exemplo, `snippet` e `brandingSettings` devem ser atualizados em chamadas separadas. | ||
- Operações como curtir comentários, definir status de moderação e outras ações sem conteúdo devem usar a abordagem de parâmetros na URL, não no corpo da requisição. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put that above the resources.
It seems that most problems that uses may have are relate to this... so, keep it up on the doc.
@@ -0,0 +1,631 @@ | |||
# App do YouTube |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English.... :) All the way.
export type GetShopInfoQueryVariables = Exact<{ | ||
identifiers: Array<HasMetafieldsIdentifier> | HasMetafieldsIdentifier; | ||
}>; | ||
|
||
|
||
export type GetShopInfoQuery = { shop: { name: string, description?: string | null, privacyPolicy?: { title: string, body: string } | null, refundPolicy?: { title: string, body: string } | null, shippingPolicy?: { title: string, body: string } | null, subscriptionPolicy?: { title: string, body: string } | null, termsOfService?: { title: string, body: string } | null, metafields: Array<{ description?: string | null, key: string, namespace: string, type: string, value: string, reference?: { image?: { url: any } | null } | {} | null, references?: { edges: Array<{ node: { image?: { url: any } | null } | {} }> } | null } | null> } }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type GetShopInfoQueryVariables = Exact<{ | |
identifiers: Array<HasMetafieldsIdentifier> | HasMetafieldsIdentifier; | |
}>; | |
export type GetShopInfoQuery = { shop: { name: string, description?: string | null, privacyPolicy?: { title: string, body: string } | null, refundPolicy?: { title: string, body: string } | null, shippingPolicy?: { title: string, body: string } | null, subscriptionPolicy?: { title: string, body: string } | null, termsOfService?: { title: string, body: string } | null, metafields: Array<{ description?: string | null, key: string, namespace: string, type: string, value: string, reference?: { image?: { url: any } | null } | {} | null, references?: { edges: Array<{ node: { image?: { url: any } | null } | {} }> } | null } | null> } }; |
should be here?
lives/types.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like a youtube specific file. not something that is universal.
( https://schema.org/VideoObject is the most related schemaOrg that I could find).
Move to youtube app.
deco.ts
Outdated
@@ -10,6 +10,7 @@ const compatibilityApps = [{ | |||
|
|||
const config = { | |||
apps: [ | |||
app("Youtube"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid upper case on app names and directories
/** | ||
* Parse SRT format captions | ||
*/ | ||
function parseSrtCaption( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utility functions, I would keep apart from the loader.
Youtube/loaders/videoCategories.ts
Outdated
try { | ||
// Construir a URL para buscar as categorias de vídeos | ||
const url = | ||
`https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode=${regionCode}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that the google base API address should be something defined on the mod.ts, and reused here and on the other API URLs.
Youtube/loaders/livestreams/list.ts
Outdated
if (response.status === 401) { | ||
mensagem = | ||
"Token de autenticação inválido ou expirado. Faça login novamente."; | ||
} else if (response.status === 403) { | ||
mensagem = | ||
"Acesso negado. Verifique se você tem permissão para listar transmissões e o escopo 'youtube.livestream' está autorizado."; | ||
} else if (response.status === 404) { | ||
mensagem = | ||
"Recurso não encontrado. Verifique se os IDs das transmissões estão corretos."; | ||
} else if (response.status === 400) { | ||
mensagem = "Solicitação inválida. Verifique os parâmetros enviados."; | ||
} else if (response.status === 500) { | ||
mensagem = | ||
"Erro interno do servidor YouTube. Tente novamente mais tarde."; | ||
} else if (response.status === 429) { | ||
mensagem = | ||
"Limite de requisições excedido. Aguarde um momento e tente novamente."; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is something that you may need to do for every response.
Youtube/actions/comments/like.ts
Outdated
return { | ||
success: false, | ||
message: `Erro ao avaliar comentário: ${error.message}`, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should create a uniform API.
you can either... all return success with { data: any, error: Error }, which is a more common patter for APIs, or return data if successful, and throw an exception otherwise.
Usually I am more prone to the return data/exception for user facing APIs and data/error pattern for libraries (such as postgres).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This success/message seems confusing, since you are probably defining a UI message to be set by the API. And message means two different things here (error message or successful message if the success is true or false).
Youtube/actions/updateChannel.ts
Outdated
return { success: false, message: "Autenticação necessária" }; | ||
} | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try catchs are too big on your functions. create a separate call for that logic, and wrap it inside here.
try {
trueActionFn(props);
} catch (err) {
// do something
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why not to use the google-data-api?
…code, as well as update the import structure and improve code readability
…tor the access token management framework, including adding functions for cookie handling
… functionality in various YouTube actions and uploaders
…be API, improving type structure and code readability
…rs to English, improving code consistency and clarity
…o get the access token and channel data, and moving the default authentication URL to constants
…ode and adjusting the return structure of the authentication function
…g new fields and improving handling of YouTube API responses
…ing logic, including error handling and improved response structure
…ubtitle text loader and improving the response structure and configuration options
…Tube channels and videos, improving the efficiency and structure of responses
…regamento de canais e vídeos do YouTube, melhorando a eficiência e a estrutura das respostas
…ing YouTube video comments and categories, improving response structure and code efficiency
…ndling in YouTube API requests, improving response structure and code efficiency
…details interface, improving response structure and authentication logic
…tions, improving error handling, and refining response structure for better performance
…s on YouTube, adding new error interfaces and improving the structure of responses for greater efficiency
…rfaces. Standardize authentication via getAccessToken(req). Refactor and clean up YouTube integration
…rs, and improve type safety
What is this Contribution About?
Please provide a brief description of the changes or enhancements you are proposing in this pull request.
Issue Link
Please link to the relevant issue that this pull request addresses:
Loom Video
Demonstration Link